Changeset 97d3d9d in mainline
- Timestamp:
- 2023-04-20T18:43:15Z (20 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cdf5361
- Parents:
- 37087c8
- Location:
- uspace/app/display-cfg
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/display-cfg/display-cfg.c
r37087c8 r97d3d9d 36 36 #include <stdio.h> 37 37 #include <stdlib.h> 38 #include <str.h>39 38 #include <ui/fixed.h> 40 39 #include <ui/resource.h> … … 69 68 * @return EOK on success or an error code 70 69 */ 71 static errno_t display_cfg_create(const char *display_spec, 72 display_cfg_t **rdcfg) 70 errno_t display_cfg_create(const char *display_spec, display_cfg_t **rdcfg) 73 71 { 74 72 ui_t *ui = NULL; … … 179 177 * @param dcfg Display configuration dialog 180 178 */ 181 staticvoid display_cfg_destroy(display_cfg_t *dcfg)179 void display_cfg_destroy(display_cfg_t *dcfg) 182 180 { 183 181 ui_window_destroy(dcfg->window); … … 185 183 } 186 184 187 static void print_syntax(void)188 {189 printf("Syntax: display-cfg [-d <display-spec>]\n");190 }191 192 int main(int argc, char *argv[])193 {194 const char *display_spec = UI_ANY_DEFAULT;195 display_cfg_t *dcfg;196 errno_t rc;197 int i;198 199 i = 1;200 while (i < argc && argv[i][0] == '-') {201 if (str_cmp(argv[i], "-d") == 0) {202 ++i;203 if (i >= argc) {204 printf("Argument missing.\n");205 print_syntax();206 return 1;207 }208 209 display_spec = argv[i++];210 } else {211 printf("Invalid option '%s'.\n", argv[i]);212 print_syntax();213 return 1;214 }215 }216 217 if (i < argc) {218 print_syntax();219 return 1;220 }221 222 rc = display_cfg_create(display_spec, &dcfg);223 if (rc != EOK)224 return 1;225 226 ui_run(dcfg->ui);227 display_cfg_destroy(dcfg);228 229 return 0;230 }231 232 185 /** @} 233 186 */ -
uspace/app/display-cfg/display-cfg.h
r37087c8 r97d3d9d 39 39 #include "types/display-cfg.h" 40 40 41 extern errno_t display_cfg_create(const char *, display_cfg_t **); 42 extern void display_cfg_destroy(display_cfg_t *); 43 41 44 #endif 42 45 -
uspace/app/display-cfg/meson.build
r37087c8 r97d3d9d 30 30 src = files( 31 31 'display-cfg.c', 32 'main.c', 32 33 'seats.c' 33 34 ) 34 35 35 36 test_src = files( 37 'display-cfg.c', 38 'seats.c', 36 39 'test/display-cfg.c', 37 40 'test/main.c', -
uspace/app/display-cfg/seats.c
r37087c8 r97d3d9d 441 441 dcfg_devices_entry_t *dentry; 442 442 443 ui_pbutton_destroy(seats->add_device);444 ui_pbutton_destroy(seats->remove_device);445 446 ui_label_destroy(seats->devices_label);447 448 443 lentry = ui_list_first(seats->device_list); 449 444 while (lentry != NULL) { … … 454 449 lentry = ui_list_first(seats->device_list); 455 450 } 456 ui_list_destroy(seats->device_list);457 458 ui_pbutton_destroy(seats->add_seat);459 ui_pbutton_destroy(seats->remove_seat);460 451 461 452 lentry = ui_list_first(seats->seat_list); … … 468 459 } 469 460 470 ui_label_destroy(seats->seats_label); 471 ui_list_destroy(seats->seat_list); 472 ui_fixed_destroy(seats->fixed); 461 /* This will automatically destroy all controls in the tab */ 462 ui_tab_destroy(seats->tab); 473 463 free(seats); 474 464 } … … 482 472 * @return EOK on success or an error code 483 473 */ 484 staticerrno_t dcfg_seats_insert(dcfg_seats_t *seats, const char *name,474 errno_t dcfg_seats_insert(dcfg_seats_t *seats, const char *name, 485 475 sysarg_t seat_id, dcfg_seats_entry_t **rentry) 486 476 { … … 564 554 * @return EOK on success or an error code 565 555 */ 566 staticerrno_t dcfg_devices_insert(dcfg_seats_t *seats, const char *name,556 errno_t dcfg_devices_insert(dcfg_seats_t *seats, const char *name, 567 557 service_id_t svc_id) 568 558 { -
uspace/app/display-cfg/seats.h
r37087c8 r97d3d9d 42 42 extern errno_t dcfg_seats_create(display_cfg_t *, dcfg_seats_t **); 43 43 extern void dcfg_seats_destroy(dcfg_seats_t *); 44 extern errno_t dcfg_seats_insert(dcfg_seats_t *, const char *, sysarg_t, 45 dcfg_seats_entry_t **); 46 extern errno_t dcfg_devices_insert(dcfg_seats_t *, const char *, 47 service_id_t); 44 48 45 49 #endif -
uspace/app/display-cfg/test/display-cfg.c
r37087c8 r97d3d9d 29 29 #include <errno.h> 30 30 #include <pcut/pcut.h> 31 #include <ui/ui.h> 31 32 #include "../display-cfg.h" 32 33 … … 35 36 PCUT_TEST_SUITE(display_cfg); 36 37 37 //XXX TODO 38 /** Test display_cfg_create() and display_cfg_destroy() */ 39 PCUT_TEST(create_destroy) 40 { 41 display_cfg_t *dcfg; 42 errno_t rc; 43 44 rc = display_cfg_create(UI_DISPLAY_NULL, &dcfg); 45 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 46 47 display_cfg_destroy(dcfg); 48 } 38 49 39 50 PCUT_EXPORT(display_cfg); -
uspace/app/display-cfg/test/seats.c
r37087c8 r97d3d9d 29 29 #include <errno.h> 30 30 #include <pcut/pcut.h> 31 #include "../display-cfg.h" 31 32 #include "../seats.h" 32 33 … … 35 36 PCUT_TEST_SUITE(seats); 36 37 37 //XXX TODO 38 /** Test dcfg_seats_create() and dcfg_seats_destroy() */ 39 PCUT_TEST(create_destroy) 40 { 41 display_cfg_t *dcfg; 42 dcfg_seats_t *seats; 43 errno_t rc; 44 45 rc = display_cfg_create(UI_DISPLAY_NULL, &dcfg); 46 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 47 48 rc = dcfg_seats_create(dcfg, &seats); 49 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 50 51 dcfg_seats_destroy(seats); 52 display_cfg_destroy(dcfg); 53 } 54 55 /** dcfg_seats_insert() inserts an entry into the seat list */ 56 PCUT_TEST(seats_insert) 57 { 58 display_cfg_t *dcfg; 59 dcfg_seats_t *seats; 60 dcfg_seats_entry_t *entry = NULL; 61 errno_t rc; 62 63 rc = display_cfg_create(UI_DISPLAY_NULL, &dcfg); 64 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 65 66 rc = dcfg_seats_create(dcfg, &seats); 67 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 68 69 rc = dcfg_seats_insert(seats, "Alice", 42, &entry); 70 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 71 PCUT_ASSERT_NOT_NULL(entry); 72 73 PCUT_ASSERT_STR_EQUALS("Alice", entry->name); 74 PCUT_ASSERT_INT_EQUALS(42, entry->seat_id); 75 76 dcfg_seats_destroy(seats); 77 display_cfg_destroy(dcfg); 78 } 79 80 //??? Requires us to create a test display config service 81 PCUT_TEST(seats_list_populate) 82 { 83 } 84 85 /** dcfg_devices_insert() inserts an entry into the device list */ 86 PCUT_TEST(devices_insert) 87 { 88 display_cfg_t *dcfg; 89 dcfg_seats_t *seats; 90 ui_list_entry_t *lentry; 91 dcfg_devices_entry_t *entry; 92 errno_t rc; 93 94 rc = display_cfg_create(UI_DISPLAY_NULL, &dcfg); 95 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 96 97 rc = dcfg_seats_create(dcfg, &seats); 98 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 99 100 rc = dcfg_devices_insert(seats, "mydevice", 42); 101 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 102 103 lentry = ui_list_first(seats->device_list); 104 PCUT_ASSERT_NOT_NULL(lentry); 105 entry = (dcfg_devices_entry_t *)ui_list_entry_get_arg(lentry); 106 PCUT_ASSERT_NOT_NULL(entry); 107 108 PCUT_ASSERT_STR_EQUALS("mydevice", entry->name); 109 PCUT_ASSERT_INT_EQUALS(42, entry->svc_id); 110 111 dcfg_seats_destroy(seats); 112 display_cfg_destroy(dcfg); 113 } 114 115 PCUT_TEST(avail_devices_insert) 116 { 117 } 118 119 PCUT_TEST(asgn_dev_list_populate) 120 { 121 } 122 123 PCUT_TEST(avail_dev_list_populate) 124 { 125 } 126 127 PCUT_TEST(seats_get_selected) 128 { 129 } 130 131 PCUT_TEST(devices_get_selected) 132 { 133 } 134 135 PCUT_TEST(seats_list_selected) 136 { 137 } 138 139 PCUT_TEST(add_seat_clicked) 140 { 141 } 142 143 PCUT_TEST(remove_seat_clicked) 144 { 145 } 146 147 PCUT_TEST(add_seat_dialog_bok) 148 { 149 } 150 151 PCUT_TEST(add_seat_dialog_bcancel) 152 { 153 } 154 155 PCUT_TEST(add_seat_dialog_close) 156 { 157 } 158 159 PCUT_TEST(add_device_clicked) 160 { 161 } 162 163 PCUT_TEST(remove_device_clicked) 164 { 165 } 166 167 PCUT_TEST(add_device_dialog_bok) 168 { 169 } 170 171 PCUT_TEST(add_device_dialog_bcancel) 172 { 173 } 174 175 PCUT_TEST(add_device_dialog_close) 176 { 177 } 38 178 39 179 PCUT_EXPORT(seats);
Note:
See TracChangeset
for help on using the changeset viewer.