1
0
mirror of https://gitlab.gnome.org/GNOME/nautilus synced 2024-06-30 23:46:35 +00:00
Commit Graph

301 Commits

Author SHA1 Message Date
António Fernandes
25f445f4d7 tests: Use localsearch3 test-sandbox
Test sandbox program has been moved from the `TinySPARQL` (previously
`tracker`) project to `localsearch` (previously `tracker-miners`).

067e855151
abc100fa6b
2024-06-12 10:46:19 +00:00
Khalid Abu Shawarib
d4bc511f69 test/file-utilities-get-common-filename-prefix: Add tests
Adds tests for `nautilus_get_common_filename_prefix()`
2024-06-04 01:59:56 +00:00
Khalid Abu Shawarib
89ae1730b9 test/file-utilities-get-common-filename-prefix: Increase test level
Embed the existing tests in a new category in preperation for
adding another one.
2024-06-04 01:59:56 +00:00
Khalid Abu Shawarib
7aa10af359 tests: Use g_assert_true instead of g_assert 2024-03-30 08:05:34 +00:00
Jeremy Bícha
02be9a5d73 test-filename-util: fully remove artificial copy test
This is a follow-up from d2f2201df5

Fixes #3322
2024-02-23 14:35:22 +00:00
Peter Eisenmann
d2f2201df5 test-filename-util: remove artificial copy test
This breaks on 32-bit systems and generally is not very helpful to have.

Fixes #3322
2024-02-22 23:19:42 +00:00
Corey Berla
e806c29d71 file-utilities: Remove unused function 2024-01-31 01:23:33 +00:00
Peter Eisenmann
fcffac9f6e general: make all headers end with one newline
Some IDEs automatically add them, leading to undesired changes in MRs.
Add them to avoid any such issues in the future.
2024-01-29 14:11:03 +01:00
Khalid Abu Shawarib
2d12c4714d test/file-operations: Use proper file checks
Null pointer checks on files returned by g_file_new_for_path and
g_file_get_child are not useful. Replace them with existance
check for existing files and drop them for files that are yet
to be created.
2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
3350dc491e test/file-operations: Remove deep checks after hierarchy creation
These checks tests files nested in a file structure. They are
only used for checking and nothing else in their respective
functions. They are also logically wrong, but that is addressed in
the next commit.
2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
289a1da5ee test/utilities: Use GStrv to build file test hierarchies 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
de9e8e9193 test/utilities: Simplifiy callback signal connection 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
177ccc03c9 test/utilities: Remove whitespace and unused variables 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
1cecb514a0 test/utilities: Use a GStrv to build search hierarchy
Use a string array representation to make the search file
hierarchy representation more readable and require less manual
and repetitive code.
2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
a9580d511b test: Rework variables and fix leaks 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
0402505f2f test/file-operations-trash: Refactor delete verification 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
e83a8ca0a5 test/file-operations-trash: Remove useless check
There's no point in checking if a child of a non-existent file
doesn't exist.
2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
0ddd7a12c6 test/file-operations-move: Refactor move verification 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
56b2198fca test/file-operations-move: Use directories in corresponding tests 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
2ea6106398 test/file-operations-copy: Refactor copy verification 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
5ffc009753 test/utilities: Fix basename leak 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
5eda0a05cf test/utilities: Rename misleading directories names 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
d49c5c02b5 test/file-operations-trash: Disambiguate delete files/dirs names 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
8c139d6b94 test/file-operations-trash: Refactor repetitive delete code 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
dad7ccf0bf test/file-operations-trash: Refactor repetitive trash code 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
d1015c4148 test/file-operations-move: Refactor repetitive move code 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
0b439a3e80 test/file-operations-copy: Refactor repetitive copy code 2023-12-15 10:53:37 +00:00
Khalid Abu Shawarib
02807a3df0 test/file-operations-copy: Unify code in loops
Add missing free functions and reorder a statment so that loops
become uniform.
2023-12-15 10:53:37 +00:00
Peter Eisenmann
9dfbe86bcd general: simple un<>signed comparison fixes
A collection of simple fixes for comparison warnings.
2023-11-18 00:40:09 +01:00
Peter Eisenmann
d4526131c1 filename-util: add conflict name creation helper
Add a helper function that appends a bracketed number to the end of a
file name, and can also detect previous numbers. Adjust functions in
file-operations and file-util to use it for handling conflicts. Also,
add unittests for it.
2023-11-16 02:36:20 +01:00
Peter Eisenmann
3649989cd1 filename-util: fix copy name appendix handling
When checking file names for previous copy appendices, check the length
of the appendix. Without this names such as "file (Copy 2 Disk)" would
have triggered appendix detection and resulted in "file (Copy 3)" as a
file name.

Add unittests to cover this case. Also adjust long number unittest to
fit in 32 bits.
2023-11-16 01:25:18 +00:00
Peter Eisenmann
6e3befd73e filename-util: check for space in name parsing
Duplication appendices added start with a space, so when parsing
previous names make sure that such a space exists too.

Also, fix incorrect unittest and use the term appendix more uniformly.
2023-11-16 01:25:18 +00:00
Peter Eisenmann
6c2fbfbe13 test-filename-util: split file and dir copy tests
Also use g_autofree by block scoping macro.
2023-11-16 01:25:18 +00:00
Peter Eisenmann
2a19769d2b filename-util: rename create_duplicate to for_copy
This matches the name scheme of `nautilus_filename_for_link` and
clarifies the functions specific use case.

Also fix a documentation mistake.
2023-11-16 01:25:18 +00:00
Peter Eisenmann
eada641e09 file: make get_metadata return const string
To avoid needless string copies, make nautilus_file_get_metadata return
a const char* rather then a string copy that has to be freed. Adjust
usages accordingly.
2023-11-13 20:17:36 +00:00
Peter Eisenmann
eb75ddad9a file: make get_name return const string
To avoid needless string copies, make nautilus_file_get_name return a
const char* rather then a string copy that has to be freed. Adjust usage
accordingly.
2023-11-13 20:17:36 +00:00
António Fernandes
8ec1244c3e file: Drop deep ref/unref wrappers
Their names are misleading: the list itself is not refcounted.

This misconception is likely how some memory leaks have been
introduced in nautilus_restore_files_from_trash() and in
properties_cb(). Both leaks are therefore fixed as part of
this commit by employing autocleanup in the first case and
stack allocation in the second case.
2023-11-01 13:13:04 +00:00
António Fernandes
8095f3d114 filename-utilities: Mark passed string arrays as const
The functions are going to read but not modify them.
2023-11-01 13:13:04 +00:00
António Fernandes
b806b4edbb file-utilities: Use string arrays, not linked lists
We don't sort or insert in the middle, linked lists gain us nothing.

Arrays offer better cache locality and even shorter code.
2023-11-01 13:05:40 +00:00
Peter Eisenmann
2aeb0dd80d file-private: expose new_from_filename()
To not need to include a .c file in test-file-utilities, expose
nautilus_file_new_from_filename in nautilus-file-private.h and adjust
the includes accordingly.
2023-11-01 00:56:27 +01:00
Peter Eisenmann
d96d968ee2 build: sort tests alphabetically 2023-10-31 22:19:46 +00:00
Peter Eisenmann
095664a420 filename-util: integrate common prefix detection
Integrate `eel_str_get_common_prefix` as `nautilus_filename_get_common_prefix`
into filename utilities. Rename the unittest to reflect this.

eel-string.h is no longer needed with this change, so it is removed.
2023-10-31 22:19:46 +00:00
Peter Eisenmann
f5633d1ea7 ui-util: integrate string capitalization function
Integrate `eel_str_capitalize` as `nautilus_capitalize_str` into ui utilities
and turn the self-check functionality into a unittest.
2023-10-31 22:19:46 +00:00
Peter Eisenmann
43b6c59148 general: remove unused eel-string includes 2023-10-31 22:19:46 +00:00
Peter Eisenmann
9bbf8f186a file: turn self-check into proper unittests
Unittests are more straightforward to run than the eel self-check
mechanism. This also allows removing eel dependencies. The tests
are split up to make them more comprehensible.
2023-10-31 22:19:46 +00:00
Peter Eisenmann
9322a3d2ae file-operations: turn self-check into proper unittests
Turn the file duplication testing code into a dedicated unittest.
Unittests are more straightforward to run than the eel self-check
mechanism. This also allows dropping eel dependencies and reduces
the size of the file-operations file.

The concrete duplication syntax is abstracted away with a macro for
better readability of the comparisons.
2023-10-31 22:19:46 +00:00
Peter Eisenmann
4d3ad41a5c filename-util: add extension detector
The new `nautilus_filename_get_extension` function is similar to the
previous `eel_filename_get_extension_offset` function, but differs
in some ways:
 * It does not accept NULL
 * It returns a pointer to \0 rather than NULL when no extension
   can be found.
 * It detects .tar.* extensions without needing a maintained list.

In the one place it was used, replace `nautilus_file_get_extension`
by instead calling `nautilus_filename_get_extension` on the file name.
Migrate usages of the previous eel function to use the new function
and remove the eel function from the header file (It is still used
in the .c file).

Also unittests.
2023-10-31 22:19:46 +00:00
Peter Eisenmann
ba4e3e10fe file-operations: shorten filenames by base
`nautilus_filename_shorten_base` shortens a file name to fit within a
certain limit, by trimming the base part of the filename. It can thus
be used to shorten file name without mangling extensions and other
suffixes. It gets used in two places where a file operation can lead to
a file name conflict and a suffix is added to resolve it.

The method is placed in a new 'filename-utilities' file to allow creating a
unittest for it, as well as in preparation for moving other file name functions
there.
2023-10-31 22:19:46 +00:00
Peter Eisenmann
48c521eb8f vfs-file: Turn file metadata tests into unittests
These were previously commented out in `file-directory.c`. They
couldn't have functioned anymore, as setting arbitrary metadata values
is prevented by the nautilus-metadata hash table.

By reusing already existing metadata tags, that don't have any effect
on the file they are used on, these tests can be reactivated.

In order to work in test environments without gvfsd-metadata running,
bypass GIO and set metadata directly.
2023-10-31 22:19:46 +00:00
Peter Eisenmann
8a6ad0451b directory: turn self-check into proper unittests
Unittests are more straightforward to run than the eel self-check
mechanism. This also allows removing eel dependencies. The tests
are split up to make them more comprehensible.
2023-10-31 22:19:46 +00:00