summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2021-01-13 09:52:01 +0100
committerOndrej Holy <oholy@redhat.com>2021-01-13 12:04:43 +0100
commitc97255cb31e0dd0e0fad07e3c0fe579eb8d61262 (patch)
tree9387d60a5b23a15cfb64f473d266a89e2c82f0bb
parentac9be83e0117c42328698cacf1372c87b437ae71 (diff)
downloadnautilus-wip/oholy/test-unique-dir.tar.gz
test: Run tests in unique directorywip/oholy/test-unique-dir
The tests currently create various files and directories with generic names and manipulate with them directly in the `/tmp` directory. The tests also remove all files in `/tmp` with the generic prefixes like `move`, `copy`, etc. This can simply cause test suite failures if files with such names already exist in the `/tmp` directory. Also, the test suite can easily remove files created by other applications. Let's always create an unique directory in `/tmp` for tests to fix the mentioned problems...
-rw-r--r--test/automated/displayless/test-file-operations-copy-files.c59
-rw-r--r--test/automated/displayless/test-file-operations-dir-has-files.c15
-rw-r--r--test/automated/displayless/test-file-operations-move-files.c85
-rw-r--r--test/automated/displayless/test-file-operations-trash-or-delete.c35
-rw-r--r--test/automated/displayless/test-nautilus-search-engine-model.c4
-rw-r--r--test/automated/displayless/test-nautilus-search-engine-simple.c4
-rw-r--r--test/automated/displayless/test-nautilus-search-engine.c4
-rw-r--r--test/automated/displayless/test-utilities.c45
-rw-r--r--test/automated/displayless/test-utilities.h3
9 files changed, 154 insertions, 100 deletions
diff --git a/test/automated/displayless/test-file-operations-copy-files.c b/test/automated/displayless/test-file-operations-copy-files.c
index 1a7d80201..605094efd 100644
--- a/test/automated/displayless/test-file-operations-copy-files.c
+++ b/test/automated/displayless/test-file-operations-copy-files.c
@@ -12,7 +12,7 @@ test_copy_one_file (void)
create_one_file ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -47,7 +47,7 @@ test_copy_one_file_undo (void)
create_one_file ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -84,7 +84,7 @@ test_copy_one_empty_directory (void)
create_one_empty_directory ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
g_assert_true (first_dir != NULL);
@@ -118,7 +118,7 @@ test_copy_one_empty_directory_undo (void)
create_one_empty_directory ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
g_assert_true (first_dir != NULL);
@@ -154,7 +154,7 @@ test_copy_files_small (void)
create_multiple_files ("copy", 10);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10; i++)
@@ -198,7 +198,7 @@ test_copy_files_small_undo (void)
create_multiple_files ("copy", 10);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10; i++)
@@ -244,7 +244,7 @@ test_copy_files_medium (void)
create_multiple_files ("copy", 1000);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 1000; i++)
@@ -288,7 +288,7 @@ test_copy_files_medium_undo (void)
create_multiple_files ("copy", 1000);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 1000; i++)
@@ -333,7 +333,7 @@ test_copy_files_large (void)
create_multiple_files ("copy", 10000);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10000; i++)
@@ -375,7 +375,7 @@ test_copy_files_large_undo (void)
create_multiple_files ("copy", 10000);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10000; i++)
@@ -421,7 +421,7 @@ test_copy_directories_small (void)
create_multiple_directories ("copy", 10);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10; i++)
@@ -465,7 +465,7 @@ test_copy_directories_small_undo (void)
create_multiple_directories ("copy", 10);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10; i++)
@@ -511,7 +511,7 @@ test_copy_directories_medium (void)
create_multiple_directories ("copy", 1000);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 1000; i++)
@@ -555,7 +555,7 @@ test_copy_directories_medium_undo (void)
create_multiple_directories ("copy", 1000);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 1000; i++)
@@ -601,7 +601,7 @@ test_copy_directories_large (void)
create_multiple_directories ("copy", 10000);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10000; i++)
@@ -645,7 +645,7 @@ test_copy_directories_large_undo (void)
create_multiple_directories ("copy", 10000);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10000; i++)
@@ -695,7 +695,7 @@ test_copy_full_directory (void)
create_one_file ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -735,7 +735,7 @@ test_copy_full_directory_undo (void)
create_one_file ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -783,7 +783,7 @@ test_copy_first_hierarchy (void)
create_first_hierarchy ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -832,7 +832,7 @@ test_copy_first_hierarchy_undo (void)
create_first_hierarchy ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -888,7 +888,7 @@ test_copy_second_hierarchy (void)
create_second_hierarchy ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
first_dir = g_file_get_child (root, "copy_first_dir");
files = g_list_prepend (files, g_object_ref (first_dir));
g_assert_true (first_dir != NULL);
@@ -935,7 +935,7 @@ test_copy_second_hierarchy_undo (void)
create_second_hierarchy ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -992,7 +992,7 @@ test_copy_third_hierarchy (void)
create_third_hierarchy ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -1062,7 +1062,7 @@ test_copy_third_hierarchy_undo (void)
create_third_hierarchy ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -1139,7 +1139,7 @@ test_copy_fourth_hierarchy (void)
create_fourth_hierarchy ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -1196,7 +1196,7 @@ test_copy_fourth_hierarchy_undo (void)
create_fourth_hierarchy ("copy");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "copy_first_dir");
@@ -1304,6 +1304,7 @@ main (int argc,
char *argv[])
{
g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+ int ret;
undo_manager = nautilus_file_undo_manager_new ();
g_test_init (&argc, &argv, NULL);
@@ -1312,5 +1313,9 @@ main (int argc,
setup_test_suite ();
- return g_test_run ();
+ ret = g_test_run ();
+
+ nautilus_clear_tmp_dir ();
+
+ return ret;
}
diff --git a/test/automated/displayless/test-file-operations-dir-has-files.c b/test/automated/displayless/test-file-operations-dir-has-files.c
index 06c7df20e..15eca3052 100644
--- a/test/automated/displayless/test-file-operations-dir-has-files.c
+++ b/test/automated/displayless/test-file-operations-dir-has-files.c
@@ -7,6 +7,7 @@
#include "src/nautilus-file-operations.c"
#include <unistd.h>
#include "eel/eel-string.h"
+#include "test-utilities.h"
/* Tests the function for a simple file */
static void
@@ -15,7 +16,7 @@ test_simple_file (void)
g_autoptr (GFile) root = NULL;
g_autoptr (GFile) file = NULL;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
file = g_file_get_child (root, "simple_file");
g_file_create (file, G_FILE_CREATE_NONE, NULL, NULL);
g_assert_false (dir_has_files (file));
@@ -29,7 +30,7 @@ test_empty_directory (void)
g_autoptr (GFile) root = NULL;
g_autoptr (GFile) child = NULL;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
child = g_file_get_child (root, "empty_dir");
g_assert_true (child != NULL);
@@ -48,7 +49,7 @@ test_directory_one_file (void)
g_autoptr (GFile) parent_dir = NULL;
g_autoptr (GFile) child_file = NULL;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
parent_dir = g_file_get_child (root, "parent_dir");
g_assert_true (parent_dir != NULL);
g_file_make_directory (parent_dir, NULL, NULL);
@@ -77,11 +78,17 @@ int
main (int argc,
char *argv[])
{
+ int ret;
+
g_test_init (&argc, &argv, NULL);
g_test_set_nonfatal_assertions ();
nautilus_ensure_extension_points ();
setup_test_suite ();
- return g_test_run ();
+ ret = g_test_run ();
+
+ nautilus_clear_tmp_dir ();
+
+ return ret;
}
diff --git a/test/automated/displayless/test-file-operations-move-files.c b/test/automated/displayless/test-file-operations-move-files.c
index 5ad8ccb51..1633b84d1 100644
--- a/test/automated/displayless/test-file-operations-move-files.c
+++ b/test/automated/displayless/test-file-operations-move-files.c
@@ -12,7 +12,7 @@ test_move_one_file (void)
create_one_file ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -48,7 +48,7 @@ test_move_one_file_undo (void)
create_one_file ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -86,7 +86,7 @@ test_move_one_file_undo_redo (void)
create_one_file ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -124,7 +124,7 @@ test_move_one_empty_directory (void)
create_one_empty_directory ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -159,7 +159,7 @@ test_move_one_empty_directory_undo (void)
create_one_empty_directory ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -196,7 +196,7 @@ test_move_one_empty_directory_undo_redo (void)
create_one_empty_directory ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -232,7 +232,7 @@ test_move_files_small (void)
create_multiple_files ("move", 10);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10; i++)
@@ -274,7 +274,7 @@ test_move_files_small_undo (void)
create_multiple_files ("move", 10);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10; i++)
@@ -320,7 +320,7 @@ test_move_files_small_undo_redo (void)
create_multiple_files ("move", 10);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10; i++)
@@ -364,7 +364,7 @@ test_move_files_medium (void)
create_multiple_files ("move", 50);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 50; i++)
@@ -406,7 +406,7 @@ test_move_files_medium_undo (void)
create_multiple_files ("move", 50);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
for (int i = 0; i < 50; i++)
{
@@ -451,7 +451,7 @@ test_move_files_medium_undo_redo (void)
create_multiple_files ("move", 50);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 50; i++)
@@ -495,7 +495,7 @@ test_move_files_large (void)
create_multiple_files ("move", 500);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
for (int i = 0; i < 500; i++)
{
@@ -540,7 +540,7 @@ test_move_files_large_undo (void)
create_multiple_files ("move", 500);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 500; i++)
@@ -583,7 +583,7 @@ test_move_files_large_undo_redo (void)
create_multiple_files ("move", 500);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 500; i++)
@@ -627,7 +627,7 @@ test_move_directories_small (void)
create_multiple_directories ("move", 10);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10; i++)
@@ -669,7 +669,7 @@ test_move_directories_small_undo (void)
create_multiple_directories ("move", 10);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
for (int i = 0; i < 10; i++)
{
@@ -714,7 +714,7 @@ test_move_directories_small_undo_redo (void)
create_multiple_files ("move", 10);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 10; i++)
@@ -758,7 +758,7 @@ test_move_directories_medium (void)
create_multiple_directories ("move", 50);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 50; i++)
@@ -800,7 +800,7 @@ test_move_directories_medium_undo (void)
create_multiple_directories ("move", 50);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
for (int i = 0; i < 50; i++)
{
@@ -845,7 +845,7 @@ test_move_directories_medium_undo_redo (void)
create_multiple_files ("move", 50);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 50; i++)
@@ -889,7 +889,7 @@ test_move_directories_large (void)
create_multiple_directories ("move", 500);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 500; i++)
@@ -931,7 +931,7 @@ test_move_directories_large_undo (void)
create_multiple_directories ("move", 500);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
for (int i = 0; i < 500; i++)
{
@@ -976,7 +976,7 @@ test_move_directories_large_undo_redo (void)
create_multiple_directories ("move", 500);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 500; i++)
@@ -1026,7 +1026,7 @@ test_move_full_directory (void)
create_one_file ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1066,7 +1066,7 @@ test_move_full_directory_undo (void)
create_one_file ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1107,7 +1107,7 @@ test_move_full_directory_undo_redo (void)
create_one_file ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1155,7 +1155,7 @@ test_move_first_hierarchy (void)
create_first_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1204,7 +1204,7 @@ test_move_first_hierarchy_undo (void)
create_first_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1255,7 +1255,7 @@ test_move_first_hierarchy_undo_redo (void)
create_first_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1311,7 +1311,7 @@ test_move_second_hierarchy (void)
create_second_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1362,7 +1362,7 @@ test_move_second_hierarchy_undo (void)
create_second_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1414,7 +1414,7 @@ test_move_second_hierarchy_undo_redo (void)
create_second_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1477,7 +1477,7 @@ test_move_third_hierarchy (void)
create_third_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
first_dir = g_file_get_child (root, "move_first_dir");
files = g_list_prepend (files, g_object_ref (first_dir));
g_assert_true (first_dir != NULL);
@@ -1544,7 +1544,7 @@ test_move_third_hierarchy_undo (void)
create_third_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1613,7 +1613,7 @@ test_move_third_hierarchy_undo_redo (void)
create_third_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "move_first_dir");
@@ -1691,7 +1691,7 @@ test_move_fourth_hierarchy (void)
create_fourth_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
first_dir = g_file_get_child (root, "move_first_dir");
files = g_list_prepend (files, g_object_ref (first_dir));
g_assert_true (first_dir != NULL);
@@ -1746,7 +1746,7 @@ test_move_fourth_hierarchy_undo (void)
create_fourth_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
first_dir = g_file_get_child (root, "move_first_dir");
files = g_list_prepend (files, g_object_ref (first_dir));
g_assert_true (first_dir != NULL);
@@ -1803,7 +1803,7 @@ test_move_fourth_hierarchy_undo_redo (void)
create_fourth_hierarchy ("move");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
first_dir = g_file_get_child (root, "move_first_dir");
files = g_list_prepend (files, g_object_ref (first_dir));
g_assert_true (first_dir != NULL);
@@ -1935,6 +1935,7 @@ main (int argc,
char *argv[])
{
g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+ int ret;
undo_manager = nautilus_file_undo_manager_new ();
g_test_init (&argc, &argv, NULL);
@@ -1943,5 +1944,9 @@ main (int argc,
setup_test_suite ();
- return g_test_run ();
+ ret = g_test_run ();
+
+ nautilus_clear_tmp_dir ();
+
+ return ret;
}
diff --git a/test/automated/displayless/test-file-operations-trash-or-delete.c b/test/automated/displayless/test-file-operations-trash-or-delete.c
index b1f410949..d1b9c515b 100644
--- a/test/automated/displayless/test-file-operations-trash-or-delete.c
+++ b/test/automated/displayless/test-file-operations-trash-or-delete.c
@@ -10,7 +10,7 @@ test_trash_one_file (void)
create_one_file ("trash_or_delete");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "trash_or_delete_first_dir");
@@ -36,7 +36,7 @@ test_trash_more_files_func (gint files_to_trash)
create_multiple_files ("trash_or_delete", files_to_trash);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < files_to_trash; i++)
@@ -81,7 +81,7 @@ test_delete_one_file (void)
create_one_file ("trash_or_delete");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "trash_or_delete_first_dir");
@@ -107,7 +107,7 @@ test_delete_more_files_func (gint files_to_delete)
create_multiple_files ("trash_or_delete", files_to_delete);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < files_to_delete; i++)
@@ -152,7 +152,7 @@ test_trash_one_empty_directory (void)
create_one_empty_directory ("trash_or_delete");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "trash_or_delete_first_dir");
@@ -180,7 +180,7 @@ test_trash_more_empty_directories_func (gint directories_to_trash)
create_multiple_directories ("trash_or_delete", directories_to_trash);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < directories_to_trash; i++)
@@ -226,7 +226,7 @@ test_delete_one_empty_directory (void)
create_one_empty_directory ("trash_or_delete");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "trash_or_delete_first_dir");
@@ -253,7 +253,7 @@ test_delete_more_empty_directories_func (gint directories_to_delete)
create_multiple_directories ("trash_or_delete", directories_to_delete);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < directories_to_delete; i++)
@@ -304,7 +304,7 @@ test_trash_full_directory (void)
create_one_file ("trash_or_delete");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "trash_or_delete_first_dir");
@@ -338,7 +338,7 @@ test_trash_first_hierarchy (void)
create_first_hierarchy ("trash_or_delete");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "trash_or_delete_first_dir");
@@ -376,7 +376,7 @@ test_trash_third_hierarchy (void)
create_multiple_full_directories ("trash_or_delete", 50);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 50; i++)
@@ -425,7 +425,7 @@ test_delete_full_directory (void)
create_one_file ("trash_or_delete");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "trash_or_delete_first_dir");
@@ -459,7 +459,7 @@ test_delete_first_hierarchy (void)
create_first_hierarchy ("trash_or_delete");
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
first_dir = g_file_get_child (root, "trash_or_delete_first_dir");
@@ -497,7 +497,7 @@ test_delete_third_hierarchy (void)
create_multiple_full_directories ("trash_or_delete", 50);
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < 50; i++)
@@ -570,6 +570,7 @@ main (int argc,
char *argv[])
{
g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+ int ret;
g_test_init (&argc, &argv, NULL);
g_test_set_nonfatal_assertions ();
@@ -578,5 +579,9 @@ main (int argc,
setup_test_suite ();
- return g_test_run ();
+ ret = g_test_run ();
+
+ nautilus_clear_tmp_dir ();
+
+ return ret;
}
diff --git a/test/automated/displayless/test-nautilus-search-engine-model.c b/test/automated/displayless/test-nautilus-search-engine-model.c
index 0a68bd797..de31d4a3b 100644
--- a/test/automated/displayless/test-nautilus-search-engine-model.c
+++ b/test/automated/displayless/test-nautilus-search-engine-model.c
@@ -59,7 +59,7 @@ main (int argc,
nautilus_query_set_text (query, "engine_model");
nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (engine), query);
- location = g_file_new_for_path (g_get_tmp_dir ());
+ location = g_file_new_for_path (nautilus_get_tmp_dir ());
directory = nautilus_directory_get (location);
model = nautilus_search_engine_get_model_provider (engine);
nautilus_search_engine_model_set_model (model, directory);
@@ -75,5 +75,7 @@ main (int argc,
g_assert_cmpint (total_hits, ==, 3);
+ nautilus_clear_tmp_dir ();
+
return 0;
}
diff --git a/test/automated/displayless/test-nautilus-search-engine-simple.c b/test/automated/displayless/test-nautilus-search-engine-simple.c
index 9657bb622..cb00b315e 100644
--- a/test/automated/displayless/test-nautilus-search-engine-simple.c
+++ b/test/automated/displayless/test-nautilus-search-engine-simple.c
@@ -57,7 +57,7 @@ main (int argc,
nautilus_query_set_text (query, "engine_simple");
nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (engine), query);
- location = g_file_new_for_path (g_get_tmp_dir ());
+ location = g_file_new_for_path (nautilus_get_tmp_dir ());
directory = nautilus_directory_get (location);
nautilus_query_set_location (query, location);
@@ -70,5 +70,7 @@ main (int argc,
g_assert_cmpint (total_hits, ==, 3);
+ nautilus_clear_tmp_dir ();
+
return 0;
}
diff --git a/test/automated/displayless/test-nautilus-search-engine.c b/test/automated/displayless/test-nautilus-search-engine.c
index cc843de6e..c604a46ab 100644
--- a/test/automated/displayless/test-nautilus-search-engine.c
+++ b/test/automated/displayless/test-nautilus-search-engine.c
@@ -58,7 +58,7 @@ main (int argc,
nautilus_query_set_text (query, "engine_all_engines");
nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (engine), query);
- location = g_file_new_for_path (g_get_tmp_dir ());
+ location = g_file_new_for_path (nautilus_get_tmp_dir ());
directory = nautilus_directory_get (location);
nautilus_query_set_location (query, location);
@@ -70,5 +70,7 @@ main (int argc,
g_assert_cmpint (total_hits, ==, 3);
+ nautilus_clear_tmp_dir ();
+
return 0;
}
diff --git a/test/automated/displayless/test-utilities.c b/test/automated/displayless/test-utilities.c
index 68014ea0e..6cabecdd4 100644
--- a/test/automated/displayless/test-utilities.c
+++ b/test/automated/displayless/test-utilities.c
@@ -1,5 +1,28 @@
#include "test-utilities.h"
+static gchar *nautilus_tmp_dir = NULL;
+
+const gchar *
+nautilus_get_tmp_dir ()
+{
+ if (nautilus_tmp_dir == NULL)
+ {
+ nautilus_tmp_dir = g_dir_make_tmp ("nautilus.XXXXXX", NULL);
+ }
+
+ return nautilus_tmp_dir;
+}
+
+void
+nautilus_clear_tmp_dir ()
+{
+ if (nautilus_tmp_dir != NULL)
+ {
+ rmdir (nautilus_tmp_dir);
+ g_clear_pointer (&nautilus_tmp_dir, g_free);
+ }
+}
+
void
empty_directory_by_prefix (GFile *parent,
gchar *prefix)
@@ -41,7 +64,7 @@ create_search_file_hierarchy (gchar *search_engine)
GFileOutputStream *out;
gchar *file_name;
- location = g_file_new_for_path (g_get_tmp_dir ());
+ location = g_file_new_for_path (nautilus_get_tmp_dir ());
file_name = g_strdup_printf ("engine_%s", search_engine);
file = g_file_get_child (location, file_name);
@@ -90,7 +113,7 @@ delete_search_file_hierarchy (gchar *search_engine)
g_autoptr (GFile) file = NULL;
gchar *file_name;
- location = g_file_new_for_path (g_get_tmp_dir ());
+ location = g_file_new_for_path (nautilus_get_tmp_dir ());
file_name = g_strdup_printf ("engine_%s", search_engine);
file = g_file_get_child (location, file_name);
@@ -215,7 +238,7 @@ create_one_file (gchar *prefix)
GFileOutputStream *out;
gchar *file_name;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
file_name = g_strdup_printf ("%s_first_dir", prefix);
@@ -251,7 +274,7 @@ create_one_empty_directory (gchar *prefix)
g_autoptr (GFile) file = NULL;
gchar *file_name;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
file_name = g_strdup_printf ("%s_first_dir", prefix);
@@ -285,7 +308,7 @@ create_multiple_files (gchar *prefix,
g_autoptr (GFile) dir = NULL;
gchar *file_name;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < number_of_files; i++)
@@ -318,7 +341,7 @@ create_multiple_directories (gchar *prefix,
g_autoptr (GFile) dir = NULL;
gchar *file_name;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < number_of_directories; i++)
@@ -349,7 +372,7 @@ create_first_hierarchy (gchar *prefix)
g_autoptr (GFile) result_file = NULL;
gchar *file_name;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
file_name = g_strdup_printf ("%s_first_dir", prefix);
@@ -390,7 +413,7 @@ create_second_hierarchy (gchar *prefix)
g_autoptr (GFile) result_file = NULL;
gchar *file_name;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
file_name = g_strdup_printf ("%s_first_dir", prefix);
@@ -431,7 +454,7 @@ create_third_hierarchy (gchar *prefix)
g_autoptr (GFile) result_file = NULL;
gchar *file_name;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
file_name = g_strdup_printf ("%s_first_dir", prefix);
@@ -488,7 +511,7 @@ create_fourth_hierarchy (gchar *prefix)
g_autoptr (GFile) result_file = NULL;
gchar *file_name;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
file_name = g_strdup_printf ("%s_first_dir", prefix);
@@ -533,7 +556,7 @@ create_multiple_full_directories (gchar *prefix,
{
g_autoptr (GFile) root = NULL;
- root = g_file_new_for_path (g_get_tmp_dir ());
+ root = g_file_new_for_path (nautilus_get_tmp_dir ());
g_assert_true (root != NULL);
for (int i = 0; i < number_of_directories; i++)
diff --git a/test/automated/displayless/test-utilities.h b/test/automated/displayless/test-utilities.h
index 878c87876..95536ad5f 100644
--- a/test/automated/displayless/test-utilities.h
+++ b/test/automated/displayless/test-utilities.h
@@ -10,6 +10,9 @@
#pragma once
+const gchar *nautilus_get_tmp_dir (void);
+void nautilus_clear_tmp_dir (void);
+
void empty_directory_by_prefix (GFile *parent,
gchar *prefix);