File tree Expand file tree Collapse file tree 5 files changed +44
-5
lines changed
Expand file tree Collapse file tree 5 files changed +44
-5
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ Almost everything in flipper firmware is built around this concept.
4848# C coding style
4949
5050- Tab is 4 spaces
51- - Use ` fbt format ` to reformat source code and check style guide before commit
51+ - Use ` ./ fbt format` to reformat source code and check style guide before commit
5252
5353## Naming
5454
Original file line number Diff line number Diff line change 1+ #include <dialogs/dialogs.h>
2+
3+ #include "../minunit.h"
4+
5+ MU_TEST (test_dialog_file_browser_set_basic_options_should_init_all_fields ) {
6+ mu_assert (
7+ sizeof (DialogsFileBrowserOptions ) == 28 ,
8+ "Changes to `DialogsFileBrowserOptions` should also be reflected in `dialog_file_browser_set_basic_options`" );
9+
10+ DialogsFileBrowserOptions options ;
11+ dialog_file_browser_set_basic_options (& options , ".fap" , NULL );
12+ // note: this assertions can safely be changed, their primary purpose is to remind the maintainer
13+ // to update `dialog_file_browser_set_basic_options` by including all structure fields in it
14+ mu_assert_string_eq (".fap" , options .extension );
15+ mu_assert_null (options .base_path );
16+ mu_assert (options .skip_assets , "`skip_assets` should default to `true" );
17+ mu_assert (options .hide_dot_files , "`hide_dot_files` should default to `true" );
18+ mu_assert_null (options .icon );
19+ mu_assert (options .hide_ext , "`hide_ext` should default to `true" );
20+ mu_assert_null (options .item_loader_callback );
21+ mu_assert_null (options .item_loader_context );
22+ }
23+
24+ MU_TEST_SUITE (dialogs_file_browser_options ) {
25+ MU_RUN_TEST (test_dialog_file_browser_set_basic_options_should_init_all_fields );
26+ }
27+
28+ int run_minunit_test_dialogs_file_browser_options () {
29+ MU_RUN_SUITE (dialogs_file_browser_options );
30+
31+ return MU_EXIT_CODE ;
32+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ int run_minunit_test_nfc();
2727int run_minunit_test_bit_lib ();
2828int run_minunit_test_float_tools ();
2929int run_minunit_test_bt ();
30+ int run_minunit_test_dialogs_file_browser_options ();
3031
3132typedef int (* UnitTestEntry )();
3233
@@ -55,6 +56,8 @@ const UnitTest unit_tests[] = {
5556 {.name = "bit_lib" , .entry = run_minunit_test_bit_lib },
5657 {.name = "float_tools" , .entry = run_minunit_test_float_tools },
5758 {.name = "bt" , .entry = run_minunit_test_bt },
59+ {.name = "dialogs_file_browser_options" ,
60+ .entry = run_minunit_test_dialogs_file_browser_options },
5861};
5962
6063void minunit_print_progress () {
Original file line number Diff line number Diff line change @@ -9,12 +9,13 @@ void dialog_file_browser_set_basic_options(
99 const char * extension ,
1010 const Icon * icon ) {
1111 options -> extension = extension ;
12+ options -> base_path = NULL ;
1213 options -> skip_assets = true;
14+ options -> hide_dot_files = true;
1315 options -> icon = icon ;
1416 options -> hide_ext = true;
1517 options -> item_loader_callback = NULL ;
1618 options -> item_loader_context = NULL ;
17- options -> base_path = NULL ;
1819}
1920
2021static DialogsApp * dialogs_app_alloc () {
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ typedef struct DialogsApp DialogsApp;
1616/****************** FILE BROWSER ******************/
1717
1818/**
19- * File browser dialog extra options
19+ * File browser dialog extra options.
20+ * This can be default-initialized using {@link dialog_file_browser_set_basic_options}.
2021 * @param extension file extension to be offered for selection
2122 * @param base_path root folder path for navigation with back key
2223 * @param skip_assets true - do not show assets folders
@@ -38,8 +39,10 @@ typedef struct {
3839} DialogsFileBrowserOptions ;
3940
4041/**
41- * Initialize file browser dialog options
42- * and set default values
42+ * Initialize file browser dialog options and set default values.
43+ * This is guaranteed to initialize all fields
44+ * so it is safe to pass pointer to uninitialized {@code options}
45+ * and assume that the data behind it becomes fully initialized after the call.
4346 * @param options pointer to options structure
4447 * @param extension file extension to filter
4548 * @param icon file icon pointer, NULL for default icon
You can’t perform that action at this time.
0 commit comments