[maemo-commits] [maemo-commits] r15888 - projects/haf/trunk/hildon-fm/tests
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Aug 25 16:34:00 EEST 2008
- Previous message: [maemo-commits] r15887 - projects/haf/branches/hildon-fm/fremantle/hildon-fm
- Next message: [maemo-commits] r15889 - projects/haf/branches/hildon-fm/fremantle/hildon-fm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: jukkkaup Date: 2008-08-25 16:33:55 +0300 (Mon, 25 Aug 2008) New Revision: 15888 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-private.c Log: * Added and modified tests based on gcov/lcov coverage information 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-25 08:00:40 UTC (rev 15887) +++ projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-chooser-dialog.c 2008-08-25 13:33:55 UTC (rev 15888) @@ -54,19 +54,23 @@ static GtkWidget *fcd_window; static GtkWidget *fcd; static GtkFileChooserAction action; +static bool inited = false; static void fx_setup_hildonfm_file_chooser_dialog_open () { - int argc = 0; - gtk_init (&argc, NULL); - g_thread_init (NULL); + if (!inited) + { + int argc = 0; + gtk_init (&argc, NULL); + g_thread_init (NULL); + } fcd_window = create_test_window (); fail_if (!HILDON_IS_WINDOW (fcd_window), "Window creation failed."); - action = GTK_FILE_CHOOSER_ACTION_SAVE; + action = GTK_FILE_CHOOSER_ACTION_OPEN; fcd = hildon_file_chooser_dialog_new (GTK_WINDOW(fcd_window), action); fail_if (!HILDON_IS_FILE_CHOOSER_DIALOG (fcd), @@ -78,11 +82,74 @@ } static void +fx_setup_hildonfm_file_chooser_dialog_save () +{ + if (!inited) + { + int argc = 0; + gtk_init (&argc, NULL); + g_thread_init (NULL); + } + + fcd_window = create_test_window (); + fail_if (!HILDON_IS_WINDOW (fcd_window), + "Window creation failed."); + + action = GTK_FILE_CHOOSER_ACTION_SAVE; + + fcd = hildon_file_chooser_dialog_new (GTK_WINDOW(fcd_window), action); + fail_if (!HILDON_IS_FILE_CHOOSER_DIALOG (fcd), + "File Chooser Dialog creation failed"); +} + +static void +fx_setup_hildonfm_file_chooser_dialog_select_folder () +{ + if (!inited) + { + int argc = 0; + gtk_init (&argc, NULL); + g_thread_init (NULL); + } + + fcd_window = create_test_window (); + fail_if (!HILDON_IS_WINDOW (fcd_window), + "Window creation failed."); + + action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; + + fcd = hildon_file_chooser_dialog_new (GTK_WINDOW(fcd_window), action); + fail_if (!HILDON_IS_FILE_CHOOSER_DIALOG (fcd), + "File Chooser Dialog creation failed"); +} + +static void +fx_setup_hildonfm_file_chooser_dialog_create_folder () +{ + if (!inited) + { + int argc = 0; + gtk_init (&argc, NULL); + g_thread_init (NULL); + } + + fcd_window = create_test_window (); + fail_if (!HILDON_IS_WINDOW (fcd_window), + "Window creation failed."); + + action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; + + fcd = hildon_file_chooser_dialog_new (GTK_WINDOW(fcd_window), action); + fail_if (!HILDON_IS_FILE_CHOOSER_DIALOG (fcd), + "File Chooser Dialog creation failed"); +} + +static void fx_teardown_hildonfm_file_chooser_dialog () { //gtk_container_remove (GTK_CONTAINER (fcd_window), fcd); //gtk_widget_hide_all (fcd_window); - + //printf ("HERE WE ARE !!!\n"); gtk_widget_destroy (fcd_window); gtk_widget_destroy (fcd); } @@ -132,32 +199,39 @@ /** * Purpose: Check if setting and getting a safe folder works */ -START_TEST (test_file_chooser_dialog_safe_folder) +START_TEST (test_file_chooser_dialog_safe_folder_uri) { gboolean ret; - gchar *folder, *result, *aux; + gchar *folder = NULL, *result = NULL, *aux = NULL; GtkTreeIter iter; folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER(fcd)); //printf("%s\n", folder); - aux = g_strconcat (folder, "/hildonfmtests/folder3/file3.txt", NULL); + aux = g_strconcat (folder, "/hildonfmtests/file1.txt", NULL); ret = hildon_file_system_model_load_uri (HILDON_FILE_CHOOSER_DIALOG(fcd)->priv->model, aux, &iter); fail_if (!ret, "Loading a uri to hildon file system model failed"); - //printf("%s\n", aux); + free (aux); + //aux = g_strconcat (folder, "/.documents", NULL); + aux = g_strconcat (folder, "/hildonfmtests", NULL); hildon_file_chooser_dialog_set_safe_folder_uri - (HILDON_FILE_CHOOSER_DIALOG(fcd), folder); + (HILDON_FILE_CHOOSER_DIALOG(fcd), aux); + //printf("%s\n", aux); //show_all_test_window (GTK_WIDGET (fcd_window)); - result = hildon_file_chooser_dialog_get_safe_folder + + //THIS IS THE ONE THAT CAUSES THE SEGMENTATION FAULT + result = hildon_file_chooser_dialog_get_safe_folder_uri (HILDON_FILE_CHOOSER_DIALOG(fcd)); - /* - if (result == NULL) - printf("NULL!\n"); - */ - fail_if (result == NULL || strcmp (result, folder) != 0, - "Setting a safe folder failed at set & get"); + + //if (result == NULL) + // printf("NULL!\n"); + + fail_if (result == NULL, + "Setting a safe folder failed at set & get: NULL returned"); + fail_if (strcmp (result, aux) != 0, + "Setting a safe folder failed at set & get: wrong value returned"); free (aux); free (folder); free (result); @@ -212,6 +286,28 @@ END_TEST /** + * Purpose: Check that the dialog can be created for all of the different + * actions + */ +START_TEST (test_file_chooser_dialog_actions) +{ + fx_setup_hildonfm_file_chooser_dialog_open (); + fx_teardown_hildonfm_file_chooser_dialog (); + inited = true; + + fx_setup_hildonfm_file_chooser_dialog_save (); + fx_teardown_hildonfm_file_chooser_dialog (); + + fx_setup_hildonfm_file_chooser_dialog_select_folder (); + fx_teardown_hildonfm_file_chooser_dialog (); + + fx_setup_hildonfm_file_chooser_dialog_create_folder (); + fx_teardown_hildonfm_file_chooser_dialog (); + inited = false; +} +END_TEST + +/** * Purpose: Check if creating a file name extensions widget works without * using named extensions */ @@ -360,7 +456,7 @@ filter = gtk_file_filter_new (); gtk_file_filter_add_mime_type (filter, "image/png"); - action = GTK_FILE_CHOOSER_ACTION_OPEN; + action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; HildonFileSystemModel *model = g_object_new (HILDON_TYPE_FILE_SYSTEM_MODEL, NULL); @@ -397,7 +493,7 @@ /* Create a test case for file chooser dialog safe folder*/ tcase_add_checked_fixture (tc1, fx_setup_hildonfm_file_chooser_dialog_open, fx_teardown_hildonfm_file_chooser_dialog); - tcase_add_test (tc1, test_file_chooser_dialog_safe_folder); + tcase_add_test (tc1, test_file_chooser_dialog_safe_folder_uri); suite_add_tcase (s, tc1); /* Create a test case for file chooser dialog boolean values*/ @@ -419,6 +515,7 @@ /* Create a test case for file chooser dialog properties*/ tcase_add_test (tc4, test_file_chooser_dialog_new_with_properties); + tcase_add_test (tc4, test_file_chooser_dialog_actions); suite_add_tcase (s, tc4); /* Return created suite */ 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-25 08:00:40 UTC (rev 15887) +++ projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-selection.c 2008-08-25 13:33:55 UTC (rev 15888) @@ -1301,6 +1301,56 @@ } END_TEST +/** + * Purpose: Check if moving the cursor to the current selection works + */ +START_TEST (test_file_selection_move_cursor_to_uri) +{ + char* start = (char *)_hildon_file_selection_get_current_folder_path (fs); + char *end = "/hildonfmtests"; + char *fake = "/fake"; + char *folder = NULL; + + folder = g_strconcat (start, end, NULL); + hildon_file_selection_move_cursor_to_uri (fs, folder); + + free (folder); + folder = g_strconcat (start, end, fake, NULL); + hildon_file_selection_move_cursor_to_uri (fs, folder); + free (folder); +} +END_TEST + +/** + * Purpose: Check if dimming and undimming selection works + */ +START_TEST (test_file_selection_dim_and_undim) +{ + GError **error; + gboolean ret; + char *start = (char *)_hildon_file_selection_get_current_folder_path (fs); + char *end = "/hildonfmtests"; + char *sub = "/folder1"; + char *folder = NULL; + + folder = g_strconcat (start, end, sub, NULL); + + ret = hildon_file_selection_select_uri (fs, folder, error); + fail_if (!ret, "Selecting uri failed at unselect all"); + /* + HildonFileSelectionPane pane = hildon_file_selection_get_active_pane(fs); + if (pane == HILDON_FILE_SELECTION_PANE_NAVIGATION) + printf ("Navigation\n"); + else + printf ("Content\n"); + */ + hildon_file_selection_dim_current_selection(fs); + hildon_file_selection_undim_all(fs); + + free (folder); +} +END_TEST + /* ---------- Suite creation ---------- */ Suite *create_hildonfm_file_selection_suite () @@ -1375,9 +1425,11 @@ tcase_add_checked_fixture (tc7, fx_setup_default_hildonfm_file_selection, fx_teardown_default_hildonfm_file_selection); 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); suite_add_tcase (s, tc7); - /* Create test case for file selection filters */ + /* Create test case for file selection paths */ tcase_add_checked_fixture (tc8, fx_setup_default_hildonfm_file_selection, fx_teardown_default_hildonfm_file_selection); tcase_add_test (tc8, test_file_selection_current_folder_path); 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-25 08:00:40 UTC (rev 15887) +++ projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-model.c 2008-08-25 13:33:55 UTC (rev 15888) @@ -83,7 +83,7 @@ START_TEST (test_file_system_model_load_local_path) { gboolean ret; - GtkTreeIter iter, iter2; + GtkTreeIter iter, iter1, iter2; GtkFilePath *path; GtkFileSystem *system = _hildon_file_system_model_get_file_system (model); char *start = (char *)_hildon_file_selection_get_current_folder_path (fs); @@ -100,6 +100,10 @@ aux = gtk_file_system_path_to_filename(system, path); //printf("%s\n", aux); + ret = hildon_file_system_model_load_local_path (model, NULL, &iter1); + fail_if (ret, + "Loading NULL as a local path to hildon file system model worked"); + ret = hildon_file_system_model_load_local_path (model, aux, &iter); fail_if (!ret, "Loading a local path to hildon file system model failed"); @@ -139,7 +143,7 @@ START_TEST (test_file_system_model_load_uri) { gboolean ret; - GtkTreeIter iter, iter2; + GtkTreeIter iter, iter1, iter2, iter3; char *start = (char *)_hildon_file_selection_get_current_folder_path (fs); char *end = "/hildonfmtests"; char *sub = "/file1.txt"; @@ -148,6 +152,12 @@ folder = g_strconcat (start, end, sub, NULL); + ret = hildon_file_system_model_load_uri (model, NULL, &iter1); + fail_if (ret, "Loading NULL as a uri to hildon file system model worked"); + + ret = hildon_file_system_model_load_uri (model, "file:///tmp", &iter3); + fail_if (ret, "Loading /tmp as a uri to hildon file system model worked"); + ret = hildon_file_system_model_load_uri (model, folder, &iter); fail_if (!ret, "Loading a uri to hildon file system model failed"); @@ -187,7 +197,7 @@ START_TEST (test_file_system_model_load_path) { gboolean ret; - GtkTreeIter iter, iter2; + GtkTreeIter iter, iter1, iter2; GtkFilePath *path; GtkFileSystem *system = _hildon_file_system_model_get_file_system (model); char *start = (char *)_hildon_file_selection_get_current_folder_path (fs); @@ -201,6 +211,10 @@ path = gtk_file_system_uri_to_path (system, folder); //printf("%s\n", (char *)path); + ret = hildon_file_system_model_load_path (model, NULL, &iter1); + fail_if (ret, + "Loading NULL as a path to hildon file system model worked"); + ret = hildon_file_system_model_load_path (model, path, &iter); fail_if (!ret, "Loading a GtkFilePath to hildon file system model failed"); @@ -546,6 +560,40 @@ END_TEST /** + * Purpose: Check if special locations work with new_item + */ +START_TEST (test_file_system_model_new_item_special_location) +{ + gboolean ret; + GtkTreeIter iter, iter1; + char *start = (char *)_hildon_file_selection_get_current_folder_path (fs); + char *end = "/.documents"; + char *sub = "/document.doc"; + char *stub = ".images"; + char *ext = NULL; + char *folder = NULL; + char *new_name = NULL; + + folder = g_strconcat (start, end, sub, NULL); + //printf ("%s\n", folder); + + ret = hildon_file_system_model_load_uri (model, folder, &iter1); + fail_if (!ret, "Loading a uri to hildon file system model failed"); + + free (folder); + folder = g_strconcat (start, end, NULL); + //printf ("%s\n", folder); + + ret = hildon_file_system_model_load_uri (model, folder, &iter); + fail_if (!ret, "Loading a uri to hildon file system model failed"); + + new_name = hildon_file_system_model_new_item (model, &iter, stub, ext); + fail_if (new_name == NULL, + "Getting a new filename failed with a special location"); +} +END_TEST + +/** * Purpose: Check if creating a new filename works when the default filename is * available using autoname_uri */ @@ -773,6 +821,43 @@ } END_TEST +/** + * Purpose: Check if making a path unavailable and available works + * Case 1: Use hildon_file_system_model_iter_available to set a folder unavail. + * Case 2: Use hildon_file_system_model_reset_available to set it avail. again + */ +START_TEST (test_file_system_model_iter_available) +{ + /*Test 1*/ + gboolean ret; + GtkTreeIter iter, iter1; + char *start = (char *)_hildon_file_selection_get_current_folder_path (fs); + char *end = "/hildonfmtests/folder3"; + char *sub = "/file3.txt"; + char *folder = NULL, *aux = NULL; + + folder = g_strconcat (start, end, NULL); + + ret = hildon_file_system_model_load_uri (model, folder, &iter); + fail_if (!ret, "Loading a uri to hildon file system model failed"); + + aux = folder; + folder = g_strconcat (aux, sub, NULL); + free (aux); + + ret = hildon_file_system_model_load_uri (model, folder, &iter1); + fail_if (!ret, "Loading a uri to hildon file system model failed"); + + hildon_file_system_model_iter_available(model, &iter, false); + + free (folder); + free (start); + + /*Test 2*/ + hildon_file_system_model_reset_available (model); +} +END_TEST + /* ------------------ Suite creation ------------------ */ Suite *create_hildonfm_file_system_model_suite () @@ -786,6 +871,7 @@ TCase *tc3 = tcase_create ("new_item_tests"); TCase *tc4 = tcase_create ("private_tests"); TCase *tc5 = tcase_create ("type_tests"); + TCase *tc6 = tcase_create ("misc_tests"); /* Create a test case for loading locations into the file system model*/ tcase_add_checked_fixture (tc1, @@ -814,6 +900,7 @@ tcase_add_test (tc3, test_file_system_model_new_item); tcase_add_test (tc3, test_file_system_model_new_item_stub_exists); tcase_add_test (tc3, test_file_system_model_new_item_not_loaded); + tcase_add_test (tc3, test_file_system_model_new_item_special_location); tcase_add_test (tc3, test_file_system_model_autoname_uri); tcase_add_test (tc3, test_file_system_model_autoname_uri_stub_exists); tcase_add_test (tc3, test_file_system_model_autoname_uri_nonexistent_folder); @@ -841,6 +928,13 @@ tcase_add_test (tc5, test_file_system_upnp); suite_add_tcase (s, tc5); + /* Create a test case for miscelanious tests not belonging to any group */ + tcase_add_checked_fixture (tc6, + fx_setup_default_hildonfm_file_system_model, + fx_teardown_default_hildonfm_file_system_model); + tcase_add_test (tc6, test_file_system_model_iter_available); + suite_add_tcase (s, tc6); + /* Return created suite */ return s; } Modified: projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-private.c =================================================================== --- projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-private.c 2008-08-25 08:00:40 UTC (rev 15887) +++ projects/haf/trunk/hildon-fm/tests/check-hildonfm-file-system-private.c 2008-08-25 13:33:55 UTC (rev 15888) @@ -136,6 +136,12 @@ fail_if (_hildon_file_system_compare_ignore_last_separator (uri1, uri8), "Comparing uri with a fake with last separator and 'file://' removed failed"); + fail_if (_hildon_file_system_compare_ignore_last_separator + (uri1, NULL) != FALSE, "Comparing uri with NULL worked"); + fail_if (_hildon_file_system_compare_ignore_last_separator + (NULL, uri1) != FALSE, "Comparing NULL with uri worked"); + fail_if (_hildon_file_system_compare_ignore_last_separator + (NULL, NULL) != FALSE, "Comparing NULL with NULL worked"); } END_TEST @@ -577,13 +583,21 @@ /** * Purpose: Check if identifying known extensions works + * Case 1: Known extension + * Case 2: Unknown extension + * Case 3: NULL */ START_TEST (test_file_system_is_known_extension) { + /* Test 1 */ fail_if (!_hildon_file_system_is_known_extension (".deb"), "Identifying a known extension as such failed"); + /* Test 2 */ fail_if (_hildon_file_system_is_known_extension (".rpm"), "Identifying an unknown extension worked unexpectedly"); + /* Test 3 */ + fail_if (_hildon_file_system_is_known_extension (NULL), + "Identifying NULL as an extension worked unexpectedly"); } END_TEST @@ -592,6 +606,7 @@ * Case 1: Extension is not required to be known * Case 2: Extension is required to be known but it is not * Case 3: Extension is required to be known and it is + * Case 4: Extension name is NULL */ START_TEST (test_file_system_search_extension) { @@ -615,6 +630,12 @@ res = _hildon_file_system_search_extension (name, only_known, is_folder); fail_if (strcmp (res, ".deb"), "Searching for a known extension failed"); + + /* Test 4 */ + name = NULL; + res = _hildon_file_system_search_extension (name, only_known, is_folder); + fail_if (res, "Searching for an extension from NULL worked unexpectedly"); + } END_TEST
- Previous message: [maemo-commits] r15887 - projects/haf/branches/hildon-fm/fremantle/hildon-fm
- Next message: [maemo-commits] r15889 - projects/haf/branches/hildon-fm/fremantle/hildon-fm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]