[maemo-commits] [maemo-commits] r15910 - projects/haf/trunk/hildon-fm/tests

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Aug 27 15:29:51 EEST 2008
Author: jukkkaup
Date: 2008-08-27 15:29:50 +0300 (Wed, 27 Aug 2008)
New Revision: 15910

Added:
   projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-info.c
Modified:
   projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-chooser-dialog.c
   projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-selection.c
   projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-model.c
   projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-special-location.c
   projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-storage-dialog.c
Log:
Modified and added tests to hildon-fm based on coverage data



Modified: projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-chooser-dialog.c
===================================================================
--- projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-chooser-dialog.c	2008-08-27 11:28:03 UTC (rev 15909)
+++ projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-chooser-dialog.c	2008-08-27 12:29:50 UTC (rev 15910)
@@ -27,7 +27,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
-#include <assert.h>
 #include <string.h>
 #include <stdbool.h>
 #include <sys/stat.h>

Modified: projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-selection.c
===================================================================
--- projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-selection.c	2008-08-27 11:28:03 UTC (rev 15909)
+++ projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-selection.c	2008-08-27 12:29:50 UTC (rev 15910)
@@ -258,6 +258,9 @@
  * Purpose: Check if setting and getting current folder's uri works
  * Case 1: Set a new uri
  * Case 2: Set an already selected uri
+ * Case 3: Set uri of a file
+ * Case 4: Set non-existent folder
+ * Case 5: Set NULL
  */
 START_TEST (test_file_selection_current_folder_uri)
 {
@@ -268,9 +271,11 @@
     GError **error = NULL;
     char *start = (char *)_hildon_file_selection_get_current_folder_path (fs);
     char *end = "/hildonfmtests";
-    char* sub = "/folder2";
+    char *sub = "/folder2";
+    char *file = "/file1.txt";
+    char *fake = "/fake";
     char *folder = NULL;
-    char *aux;
+    char *aux = NULL;
 
     folder = g_strconcat (start, end, NULL);
 
@@ -281,6 +286,7 @@
 
     ret = hildon_file_selection_set_current_folder_uri (fs, folder, error);
     fail_if (!ret, "Setting uri of the current folder failed at set & get");
+
     uri = hildon_file_selection_get_current_folder_uri (fs);
     fail_if (strcmp (uri, folder) != 0,
              "Setting current folder's uri succeeded but wrong uri set");
@@ -289,29 +295,73 @@
     ret = hildon_file_selection_get_current_folder_iter (fs, &iter);
     fail_if (!ret,
              "Getting iterator of the current folder failed at set & get");
+
     gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
                         HILDON_FILE_SYSTEM_MODEL_COLUMN_URI, &uri2, -1);
     fail_if (strcmp (uri, uri2) != 0, "Uri comparison failed at set & get");
 
-    /* Test 2: Test if changing the current folder's uri works */
-    aux = g_strconcat (folder, sub, NULL);
     free (folder);
-    folder = aux;
 
+    /* Test 2: Test if changing the current folder's uri works */
+    folder = g_strconcat (start, end, sub, NULL);
+
     ret = hildon_file_selection_set_current_folder_uri (fs, folder, error);
     fail_if (!ret,
              "Setting uri of the current folder failed when changing folder");
+
     uri = hildon_file_selection_get_current_folder_uri (fs);
     fail_if (strcmp (uri, folder) != 0,
              "Changing current folder's uri succeeded but wrong uri set");
 
     ret = hildon_file_selection_get_current_folder_iter (fs, &iter);
     fail_if (!ret, "Getting iterator of the current folder failed when changing folder");
+
     gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
                         HILDON_FILE_SYSTEM_MODEL_COLUMN_URI, &uri2, -1);
     fail_if (strcmp (uri, uri2) != 0,
              "Uri comparison failed when changing folder");
 
+    free (folder);
+
+    /* Test 3: Test if setting a file's uri works */
+    folder = g_strconcat (start, end, file, NULL);
+
+    ret = hildon_file_selection_set_current_folder_uri (fs, folder, error);
+    fail_if (!ret,
+             "Setting uri of the current folder failed with a file's uri");
+
+    uri = hildon_file_selection_get_current_folder_uri (fs);
+    fail_if (strcmp (uri, folder) == 0,
+             "A file's uri was set as current folder's uri");
+
+    free (folder);
+
+    folder = g_strconcat (start, end, NULL);
+    fail_if (strcmp (uri, folder) != 0,
+             "Setting file's uri didn't use file's name but parent not set");
+
+    /* Test 4: Test if setting a non-existent uri works */
+    aux = folder;
+    folder = g_strconcat (start, end, fake, NULL);
+
+    ret = hildon_file_selection_set_current_folder_uri (fs, folder, error);
+    fail_if (ret,
+             "Setting uri of the current folder succeeded with non-existent");
+
+    uri = hildon_file_selection_get_current_folder_uri (fs);
+    fail_if (strcmp (uri, aux) != 0,
+             "Setting non-existent failed but current folder still changed");
+
+    /* Test 5: Test if setting NULL works */
+    ret = hildon_file_selection_set_current_folder_uri (fs, NULL, error);
+    fail_if (ret,
+             "Setting uri of the current folder succeeded with NULL");
+
+    uri = hildon_file_selection_get_current_folder_uri (fs);
+    fail_if (strcmp (uri, aux) != 0,
+             "Setting NULL failed but current folder still changed");
+
+    free (aux);
     free (start);
     free (folder);
 }
@@ -923,6 +973,8 @@
     char *start = (char *)_hildon_file_selection_get_current_folder_path (fs);
     char *end = "/hildonfmtests";
     char* sub = "/folder2";
+    char *file = "/file1.txt";
+    char *fake = "/fake";
     char *folder = NULL;
     char *aux = NULL;
 
@@ -940,11 +992,15 @@
     uri2 = gtk_file_system_path_to_uri (system, path2);
     fail_if (strcmp (uri, uri2) != 0,
              "Path comparison failed at set & get");
+ 
+    free (folder);
+    free (path);
+    free (path2);
+    free (uri);
+    free (uri2);
 
     /* Test 2: Test if changing the current folder's path works */
-    aux = g_strconcat (folder, sub, NULL);
-    free (folder);
-    folder = aux;
+    folder = g_strconcat (start, end, sub, NULL);
 
     path = gtk_file_system_uri_to_path(system, folder);
     ret = _hildon_file_selection_set_current_folder_path (fs, path, error);
@@ -960,8 +1016,82 @@
     fail_if (strcmp (uri, uri2) != 0,
              "Path comparison failed when changing folder");
 
+    free (folder);
+    free (path);
+    free (path2);
+    free (uri);
+    free (uri2);
+
+    /* Test 3: Test if setting a file's uri works */
+    folder = g_strconcat (start, end, file, NULL);
+
+    path = gtk_file_system_uri_to_path(system, folder);
+    ret = _hildon_file_selection_set_current_folder_path (fs, path, error);
+    fail_if (!ret,
+             "Setting path of the current folder failed with file's path");
+
+    uri = hildon_file_selection_get_current_folder_uri (fs);
+    fail_if (strcmp (uri, folder) == 0,
+             "A file's path was set as current folder's path");
+
+    free (folder);
+    folder = g_strconcat (start, end, NULL);
+    fail_if (strcmp (uri, folder) != 0,
+             "Setting file's path didn't use file's name but parent not set");
+
+    path2 = _hildon_file_selection_get_current_folder_path (fs);
+    uri2 = gtk_file_system_path_to_uri (system, path2);
+    fail_if (strcmp (uri, uri2) != 0,
+             "Path comparison failed with file's name");
+
+    free (path);
+    free (path2);
+    free (uri);
+    free (uri2);
+
+    /* Test 4: Test if setting a non-existent uri works */
+    aux = folder;
+    folder = g_strconcat (start, end, fake, NULL);
+
+    path = gtk_file_system_uri_to_path(system, folder);
+    ret = _hildon_file_selection_set_current_folder_path (fs, path, error);
+    fail_if (ret,
+             "Setting path of the current folder failed with non-existent");
+
+    uri = hildon_file_selection_get_current_folder_uri (fs);
+    fail_if (strcmp (uri, aux) != 0,
+             "Setting non-existent failed but current folder still changed");
+
+    path2 = _hildon_file_selection_get_current_folder_path (fs);
+    uri2 = gtk_file_system_path_to_uri (system, path2);
+    fail_if (strcmp (uri, uri2) != 0,
+             "Path comparison failed with non-existent location");
+
     free (start);
     free (folder);
+    free (path);
+    free (path2);
+    free (uri);
+    free (uri2);
+
+    /* Test 5: Test if setting NULL works */
+    ret = _hildon_file_selection_set_current_folder_path (fs, NULL, error);
+    fail_if (ret,
+             "Setting path of the current folder failed with NULL");
+
+    uri = hildon_file_selection_get_current_folder_uri (fs);
+    fail_if (strcmp (uri, aux) != 0,
+             "Setting NULL failed but current folder still changed");
+
+    path2 = _hildon_file_selection_get_current_folder_path (fs);
+    uri2 = gtk_file_system_path_to_uri (system, path2);
+    fail_if (strcmp (uri, uri2) != 0,
+             "Path comparison failed with NULL");
+
+    free (aux);
+    free (path2);
+    free (uri);
+    free (uri2);
 }
 END_TEST
 
@@ -1351,6 +1481,24 @@
 }
 END_TEST
 
+/**
+ * Purpose: Check if getting the active pane works
+ */
+START_TEST (test_file_selection_get_active_pane)
+{
+    HildonFileSelectionPane pane;
+
+    pane = hildon_file_selection_get_active_pane (fs);
+    fail_if (pane != HILDON_FILE_SELECTION_PANE_NAVIGATION,
+             "Unexpected active pane returned with a file selection");
+
+    pane = hildon_file_selection_get_active_pane (NULL);
+    fail_if (pane != HILDON_FILE_SELECTION_PANE_NAVIGATION,
+             "Unexpected active pane returned with NULL");
+
+}
+END_TEST
+
 /* ---------- Suite creation ---------- */
 
 Suite *create_hildonfm_file_selection_suite ()
@@ -1427,6 +1575,7 @@
     tcase_add_test (tc7, test_file_selection_type);
     tcase_add_test (tc7, test_file_selection_move_cursor_to_uri);
     tcase_add_test (tc7, test_file_selection_dim_and_undim);
+    tcase_add_test (tc7, test_file_selection_get_active_pane);
     suite_add_tcase (s, tc7);
 
     /* Create test case for file selection paths */

Added: projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-info.c
===================================================================
--- projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-info.c	2008-08-27 11:28:03 UTC (rev 15909)
+++ projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-info.c	2008-08-27 12:29:50 UTC (rev 15910)
@@ -0,0 +1,330 @@
+/*
+ * This file is a part of hildon-fm tests
+ *
+ * Copyright (C) 2008 Nokia Corporation.  All rights reserved.
+ *
+ * Author: Jukka Kauppinen <jukka.p.kauppinen at nokia.com>
+ *
+ * Contacts: Richard Sun <richard.sun at nokia.com>
+ *           Attila Domokos <attila.domokos at 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
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * 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 <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include <check.h>
+#include <gtk/gtk.h>
+#include <gtk/gtkmain.h>
+#include <hildon/hildon-window.h>
+
+#include "hildon-file-system-info.h"
+#include "hildon-file-system-private.h"
+#include "hildon-file-common-private.h"
+#include "hildon-file-chooser-dialog.h"
+#include "test_suites.h"
+#include "check_utils.h"
+
+/* --------------------- Fixtures --------------------- */
+
+static HildonFileSystemModel *model = NULL;
+static HildonFileSelection *fs = NULL;
+static HildonFileSystemInfoHandle *fsih = NULL;
+
+static void
+fx_setup_default_hildonfm_file_system_info ()
+{
+    model = g_object_new (HILDON_TYPE_FILE_SYSTEM_MODEL, NULL);
+    fail_if (!HILDON_IS_FILE_SYSTEM_MODEL(model),
+             "File system model creation failed");
+
+    fs = HILDON_FILE_SELECTION (hildon_file_selection_new_with_model (model));
+    fail_if (!HILDON_IS_FILE_SELECTION (fs), "File selection creation failed");
+}
+
+static void
+fx_teardown_default_hildonfm_file_system_info ()
+{
+
+}
+
+struct _HildonFileSystemInfo
+{
+  gboolean free_after_callback;
+
+  GtkFileSystem *fs;
+  GtkFilePath *path;
+  GtkFileInfo *info;
+  HildonFileSystemSpecialLocation *location;
+
+  gchar *name_cache;
+  GdkPixbuf *icon_cache;
+  gint size;
+
+  GtkFileSystemHandle *get_info_handle;
+  guint idle_handler_id;
+
+  HildonFileSystemInfoCallback callback;
+  gpointer userdata;
+};
+
+typedef struct {
+  GMainLoop *loop;
+  HildonFileSystemInfo *info;
+  GError **error;
+} sync_data;
+
+static void
+sync_callback  (HildonFileSystemInfoHandle *handle,
+                HildonFileSystemInfo *info,
+                const GError *error,
+                gpointer data)
+{
+  sync_data *c = data;
+
+  g_propagate_error (c->error, error ? g_error_copy (error) : NULL);
+
+  if (info)
+    info->free_after_callback = FALSE;
+  c->info = info;
+
+  g_main_loop_quit (c->loop);
+}
+
+/* -------------------- Test cases -------------------- */
+
+/**
+ * Purpose: Check if getting and destroying a HildonFileSystemInfoHandle works
+ * Case 1: For a normal test file as uri
+ * Case 2: For a special location as uri
+ * Case 3: For NULL as uri
+ * Case 4: For a non-existent file as uri
+ */
+START_TEST (test_file_system_info_async_new)
+{
+    /* Test 1 */
+    gboolean ret;
+    GtkTreeIter iter;
+    sync_data data1, data2, data3, data4;
+    char *start = (char *)_hildon_file_selection_get_current_folder_path (fs);
+    char *end = "/hildonfmtests";
+    char *sub = "/file1.txt";
+    char *fake = "/fake";
+    char *doc = "/.documents";
+    char *folder = NULL;
+
+    folder = g_strconcat (start, end, sub, NULL);
+
+    ret = hildon_file_system_model_load_uri (model, folder, &iter);
+    fail_if (!ret, "Loading a uri to hildon file system model failed");
+
+    fsih = hildon_file_system_info_async_new (folder, sync_callback, &data1);
+    fail_if (fsih == NULL, "Info handle creation failed with test location");
+    hildon_file_system_info_async_cancel (fsih);
+
+    free (folder);
+
+    /* Test 2 */
+    folder = g_strconcat (start, doc, NULL);
+
+    fsih = hildon_file_system_info_async_new (folder, sync_callback, &data2);
+    fail_if (fsih == NULL, "Info handle creation failed with test location");
+    hildon_file_system_info_async_cancel (fsih);
+
+    free (folder);
+
+    /* Test 3 */
+    fsih = hildon_file_system_info_async_new (NULL, sync_callback, &data3);
+    fail_if (fsih != NULL, "Info handle creation worked with NULL as location");
+    hildon_file_system_info_async_cancel (fsih);
+
+    /* Test 4 */
+    folder = g_strconcat (start, fake, NULL);
+
+    fsih = hildon_file_system_info_async_new (folder, sync_callback, &data4);
+    fail_if (fsih != NULL,
+             "Info handle creation worked with a non-existent location");
+    hildon_file_system_info_async_cancel (fsih);
+
+    free (folder);
+}
+END_TEST
+
+/**
+ * Purpose: Check if getting the display name from a HildonFileSystemInfo works
+ * Case 1: For a normal test file as uri
+ * Case 2: For a special location as uri
+ */
+START_TEST (test_file_system_info_get_display_name)
+{
+    /* Test 1 */
+    gboolean ret;
+    GError **error;
+    GtkTreeIter iter;
+    sync_data data1, data2;
+    char *start = (char *)_hildon_file_selection_get_current_folder_path (fs);
+    char *end = "/hildonfmtests";
+    char *sub = "/file1.txt";;
+    char *doc = "/.documents";
+    char *folder = NULL;
+    HildonFileSystemInfo *info = NULL;
+
+    folder = g_strconcat (start, end, sub, NULL);
+
+    ret = hildon_file_system_model_load_uri (model, folder, &iter);
+    fail_if (!ret, "Loading a uri to hildon file system model failed");
+
+    fsih = hildon_file_system_info_async_new (folder, sync_callback, &data1);
+    fail_if (fsih == NULL, "Info handle creation failed with test location");
+
+    data1.loop = g_main_loop_new (NULL, 0);
+    data1.error = error;
+    g_main_loop_run (data1.loop);
+    info = data1.info;
+    fail_if (!info, "Getting a HildonFileSystemInfo with a test folder failed");
+
+    const char *name1 = hildon_file_system_info_get_display_name (info);
+    //printf ("%s\n", name1);
+    fail_if (!name1, "Getting the display name for a test file failed: NULL");
+    fail_if (strcmp (name1, sub + 1) != 0,
+             "Getting the display name for a test file failed: Wrong name");
+
+    hildon_file_system_info_free (info);
+    hildon_file_system_info_async_cancel (fsih);
+    free (folder);
+
+    /* Test 2 */
+    folder = g_strconcat (start, doc, NULL);
+
+    fsih = hildon_file_system_info_async_new (folder, sync_callback, &data2);
+    fail_if (fsih == NULL, "Info handle creation failed with test location");
+
+    data2.loop = g_main_loop_new (NULL, 0);
+    data2.error = error;
+    g_main_loop_run (data2.loop);
+    info = data2.info;
+    fail_if (!info,
+             "Getting a HildonFileSystemInfo with a special location failed");
+
+    const char *name2 = hildon_file_system_info_get_display_name (info);
+    //printf ("%s\n", name2);
+    fail_if (!name2,
+             "Getting the display name for a special location failed: NULL");
+    fail_if 
+        (strcmp (name2, "sfil_li_folder_documents") != 0,
+         "Getting the display name for a special location failed: Wrong name");
+    /*
+    fail_if 
+        (strcmp (name2, "Documents") != 0,
+         "Getting the display name for a special location failed: Wrong name");
+    */
+
+    hildon_file_system_info_free (info);
+    hildon_file_system_info_async_cancel (fsih);
+    free (folder);
+}
+END_TEST
+
+/**
+ * Purpose: Check if getting the GdkPixbuf icon works
+ * This currently does not work with Sbox because there is no icon theme
+ * DISABLED IN SUITE CREATION BELOW
+ */
+START_TEST (test_file_system_info_get_icon)
+{
+    /* Test 1 */
+    gboolean ret;
+    GError **error;
+    GdkPixbuf *pixbuf1, *pixbuf2;
+    GtkTreeIter iter;
+    sync_data data1, data2;
+    char *start = (char *)_hildon_file_selection_get_current_folder_path (fs);
+    char *end = "/hildonfmtests";
+    char *sub = "/file1.txt";;
+    char *doc = "/.documents";
+    char *folder = NULL;
+    HildonFileSystemInfo *info = NULL;
+
+    folder = g_strconcat (start, end, sub, NULL);
+
+    ret = hildon_file_system_model_load_uri (model, folder, &iter);
+    fail_if (!ret, "Loading a uri to hildon file system model failed");
+
+    fsih = hildon_file_system_info_async_new (folder, sync_callback, &data1);
+    fail_if (fsih == NULL, "Info handle creation failed with test location");
+
+    data1.loop = g_main_loop_new (NULL, 0);
+    data1.error = error;
+    g_main_loop_run (data1.loop);
+    info = data1.info;
+    fail_if (!info, "Getting a HildonFileSystemInfo with a test folder failed");
+
+    pixbuf1 = hildon_file_system_info_get_icon (info, GTK_WIDGET(fs));
+    fail_if (!GDK_IS_PIXBUF (pixbuf1),
+             "Getting a GdkPixbuf icon with test folder failed");
+
+    hildon_file_system_info_free (info);
+    hildon_file_system_info_async_cancel (fsih);
+    free (folder);
+
+    /* Test 2 */
+    folder = g_strconcat (start, doc, NULL);
+
+    fsih = hildon_file_system_info_async_new (folder, sync_callback, &data2);
+    fail_if (fsih == NULL, "Info handle creation failed with test location");
+
+    data2.loop = g_main_loop_new (NULL, 0);
+    data2.error = error;
+    g_main_loop_run (data2.loop);
+    info = data2.info;
+    fail_if (!info,
+             "Getting a HildonFileSystemInfo with a special location failed");
+
+    pixbuf2 = hildon_file_system_info_get_icon (info, GTK_WIDGET(fs));
+    fail_if (!GDK_IS_PIXBUF (pixbuf2),
+             "Getting a GdkPixbuf icon with special location failed");
+
+    hildon_file_system_info_free (info);
+    hildon_file_system_info_async_cancel (fsih);
+    free (folder);
+}
+END_TEST
+
+/* ------------------ Suite creation ------------------ */
+
+Suite *create_hildonfm_file_system_info_suite ()
+{
+    /* Create the suite */
+    Suite *s = suite_create ("HildonfmFileSystemInfo");
+
+    /* Create test cases */
+    TCase *tc1 = tcase_create ("general_tests");
+
+    /* Create test case for info creation */
+    tcase_add_checked_fixture (tc1, fx_setup_default_hildonfm_file_system_info,
+                               fx_teardown_default_hildonfm_file_system_info);
+    tcase_add_test (tc1, test_file_system_info_async_new);
+    tcase_add_test (tc1, test_file_system_info_get_display_name);
+    //tcase_add_test (tc1, test_file_system_info_get_icon);
+    suite_add_tcase (s, tc1);
+
+    /* Return created suite */
+    return s;
+}

Modified: projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-model.c
===================================================================
--- projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-model.c	2008-08-27 11:28:03 UTC (rev 15909)
+++ projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-model.c	2008-08-27 12:29:50 UTC (rev 15910)
@@ -192,6 +192,28 @@
 END_TEST
 
 /**
+ * Purpose: Check if loading non-existent uris to the file system model works
+ */
+START_TEST (test_file_system_model_load_uri_non_existent)
+{
+    gboolean ret;
+    GtkTreeIter iter;
+    char *start = (char *)_hildon_file_selection_get_current_folder_path (fs);
+    char *end = "/hildonfmtests";
+    char *sub = "/fake.txt";
+    char *folder = NULL;
+
+    folder = g_strconcat (start, end, sub, NULL);
+
+    ret = hildon_file_system_model_load_uri (model, folder, &iter);
+    fail_if (ret, "Loading a non-existent uri to the file system model worked");
+
+    free (folder);
+    free (start);
+}
+END_TEST
+
+/**
  * Purpose: Check if loading GtkFilePaths to the file system model works
  */
 START_TEST (test_file_system_model_load_path)
@@ -879,6 +901,7 @@
                                fx_teardown_default_hildonfm_file_system_model);
     tcase_add_test (tc1, test_file_system_model_load_local_path);
     tcase_add_test (tc1, test_file_system_model_load_uri);
+    tcase_add_test (tc1, test_file_system_model_load_uri_non_existent);
     tcase_add_test (tc1, test_file_system_model_load_path);
     suite_add_tcase (s, tc1);
 

Modified: projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-special-location.c
===================================================================
--- projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-special-location.c	2008-08-27 11:28:03 UTC (rev 15909)
+++ projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-special-location.c	2008-08-27 12:29:50 UTC (rev 15910)
@@ -174,19 +174,16 @@
 }
 END_TEST
 
-/*
+/**
  * Purpose: Check if getting extra info on a special location works
  */
-/*
 START_TEST (test_file_system_special_location_get_extra_info)
 {
     gchar *result = hildon_file_system_special_location_get_extra_info
         (location);
-    if (result)
-        printf("%s\n", result);
+    fail_if (result, "There was unexpectedly extra info to be found");
 }
 END_TEST
-*/
 
 /**
  * Purpose: Check if creating a child location for a special location works
@@ -228,6 +225,31 @@
 }
 END_TEST
 
+/**
+ * Purpose: Check if getting the reason for unavailability works if available
+ */
+START_TEST (test_file_system_special_location_get_unavailable_reason_not)
+{
+    gchar *reason;
+
+    reason = hildon_file_system_special_location_get_unavailable_reason
+        (location);
+    fail_if (reason, "A reason for unavailability was given when available");
+}
+END_TEST
+
+/**
+ * Purpose: Check if calling location_failed_access when it hasn't failed works
+ */
+START_TEST (test_file_system_special_location_failed_access_not)
+{
+    gboolean ret;
+
+    ret = hildon_file_system_special_location_failed_access (location);
+    fail_if (ret, "The call to failed access was accepted unexpectedly");
+}
+END_TEST
+
 /* ------------------ Suite creation ------------------ */
 
 Suite *create_hildonfm_file_system_special_location_suite ()
@@ -246,7 +268,7 @@
          fx_teardown_hildonfm_file_system_special_location);
     tcase_add_test (tc1, test_file_system_special_location_get_display_name);
     tcase_add_test (tc1, test_file_system_special_location_set_display_name);
-    //tcase_add_test (tc1, test_file_system_special_location_get_extra_info);
+    tcase_add_test (tc1, test_file_system_special_location_get_extra_info);
     suite_add_tcase (s, tc1);
 
     /* Create a test case for filesystem settings setting testing */
@@ -261,6 +283,9 @@
         (tc3, fx_setup_hildonfm_file_system_special_location_mydocs,
          fx_teardown_hildonfm_file_system_special_location);
     tcase_add_test (tc3, test_file_system_special_location_type);
+    tcase_add_test
+        (tc3, test_file_system_special_location_get_unavailable_reason_not);
+    tcase_add_test (tc3, test_file_system_special_location_failed_access_not);
     suite_add_tcase (s, tc3);
 
     /* Return created suite */

Modified: projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-storage-dialog.c
===================================================================
--- projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-storage-dialog.c	2008-08-27 11:28:03 UTC (rev 15909)
+++ projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-storage-dialog.c	2008-08-27 12:29:50 UTC (rev 15910)
@@ -71,17 +71,13 @@
     fail_if (!HILDON_IS_WINDOW (fssd_window),
              "Window creation failed.");
 
-    fssd = hildon_file_system_storage_dialog_new (fssd_window, start);
-    fail_if (!HILDON_IS_FILE_SYSTEM_STORAGE_DIALOG (fssd), 
-             "File system storage dialog creation failed");
-
     //show_all_test_window (GTK_WIDGET (fssd_window));
 }
 
 static void
 fx_teardown_hildonfm_file_system_storage_dialog ()
 {
-
+    gtk_widget_destroy (fssd);
 }
 
 /* -------------------- Test cases -------------------- */
@@ -99,14 +95,67 @@
 END_TEST
 
 /**
- * Purpose: Check if creating a new storage dialog works
+ * Purpose: Check if creating a new storage dialog works with a valid uri
  */
 START_TEST (test_file_system_storage_dialog_new)
 {
+    fssd = hildon_file_system_storage_dialog_new (fssd_window, start);
+    fail_if (!HILDON_IS_FILE_SYSTEM_STORAGE_DIALOG (fssd), 
+             "File system storage dialog creation failed");
+}
+END_TEST
 
+/**
+ * Purpose: Check if creating a new storage dialog works with NULL as uri
+ */
+START_TEST (test_file_system_storage_dialog_new_null)
+{
+    fssd = hildon_file_system_storage_dialog_new (fssd_window, NULL);
+    fail_if (!HILDON_IS_FILE_SYSTEM_STORAGE_DIALOG (fssd), 
+             "File system storage dialog creation failed");
 }
 END_TEST
 
+/**
+ * Purpose: Check if creating a new storage dialog works with NULL as uri and
+ * setting the uri afterwords works.
+ */
+START_TEST (test_file_system_storage_dialog_new_null_and_set_uri)
+{
+    fssd = hildon_file_system_storage_dialog_new (fssd_window, NULL);
+    fail_if (!HILDON_IS_FILE_SYSTEM_STORAGE_DIALOG (fssd), 
+             "File system storage dialog creation failed");
+
+    hildon_file_system_storage_dialog_set_uri (fssd, start);
+    fail_if (!HILDON_IS_FILE_SYSTEM_STORAGE_DIALOG (fssd), 
+             "Setting the uri of the storage dialog failed");
+}
+END_TEST
+
+/**
+ * Purpose: Check if creating a new storage dialog works with file:///tmp as uri
+ */
+START_TEST (test_file_system_storage_dialog_new_tmp)
+{
+    fssd = hildon_file_system_storage_dialog_new (fssd_window, "file:///tmp");
+    fail_if (!HILDON_IS_FILE_SYSTEM_STORAGE_DIALOG (fssd), 
+             "File system storage dialog creation failed");
+}
+END_TEST
+
+/**
+ * Purpose: Check if creating a new storage dialog works with a special location
+ */
+START_TEST (test_file_system_storage_dialog_new_special_location)
+{
+    char *folder = g_strconcat (start, ".documents", NULL);
+
+    fssd = hildon_file_system_storage_dialog_new (fssd_window, folder);
+    fail_if (!HILDON_IS_FILE_SYSTEM_STORAGE_DIALOG (fssd), 
+             "File system storage dialog creation failed");
+}
+END_TEST
+
 /* ------------------ Suite creation ------------------ */
 
 Suite *create_hildonfm_file_system_storage_dialog_suite ()
@@ -116,15 +165,23 @@
 
     /* Create test cases */
     TCase *tc1 = tcase_create ("general_tests");
+    TCase *tc2 = tcase_create ("creation_tests");
 
-    /* Create a test case for general filesystem settings testing */
-    tcase_add_checked_fixture
-        (tc1, fx_setup_hildonfm_file_system_storage_dialog,
-         fx_teardown_hildonfm_file_system_storage_dialog);
+    /* Create a test case for general storage dialog testing */
     tcase_add_test (tc1, test_file_system_storage_dialog_type);
-    tcase_add_test (tc1, test_file_system_storage_dialog_new);
     suite_add_tcase (s, tc1);
 
+    /* Create a test case for creating storage dialogs */
+    tcase_add_checked_fixture
+        (tc2, fx_setup_hildonfm_file_system_storage_dialog,
+         fx_teardown_hildonfm_file_system_storage_dialog);
+    tcase_add_test (tc2, test_file_system_storage_dialog_new);
+    tcase_add_test (tc2, test_file_system_storage_dialog_new_null);
+    tcase_add_test (tc2, test_file_system_storage_dialog_new_null_and_set_uri);
+    tcase_add_test (tc2, test_file_system_storage_dialog_new_tmp);
+    tcase_add_test (tc2, test_file_system_storage_dialog_new_special_location);
+    suite_add_tcase (s, tc2);
+
     /* Return created suite */
     return s;
 }


More information about the maemo-commits mailing list