source: mainline/uspace/app/taskbar-cfg/test/startmenu.c@ b1397ab

topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b1397ab was cb2894e, checked in by Jiri Svoboda <jiri@…>, 22 months ago

Taskbar configuration utility (WIP)

  • Property mode set to 100644
File size: 6.7 KB
Line 
1/*
2 * Copyright (c) 2023 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <async.h>
30#include <dispcfg.h>
31#include <dispcfg_srv.h>
32#include <errno.h>
33#include <pcut/pcut.h>
34#include <str.h>
35#include <testdc.h>
36#include "../display-cfg.h"
37#include "../seats.h"
38
39PCUT_INIT;
40
41PCUT_TEST_SUITE(seats);
42
43static const char *test_dispcfg_server = "test-dispcfg";
44static const char *test_dispcfg_svc = "test/dispcfg";
45
46/** Test dcfg_seats_create() and dcfg_seats_destroy() */
47PCUT_TEST(create_destroy)
48{
49 display_cfg_t *dcfg;
50 dcfg_seats_t *seats;
51 errno_t rc;
52
53 rc = display_cfg_create(UI_DISPLAY_NULL, &dcfg);
54 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
55
56 rc = dcfg_seats_create(dcfg, &seats);
57 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
58
59 dcfg_seats_destroy(seats);
60 display_cfg_destroy(dcfg);
61}
62
63/** dcfg_seats_insert() inserts an entry into the seat list */
64PCUT_TEST(seats_insert)
65{
66 display_cfg_t *dcfg;
67 dcfg_seats_t *seats;
68 dcfg_seats_entry_t *entry = NULL;
69 errno_t rc;
70
71 rc = display_cfg_create(UI_DISPLAY_NULL, &dcfg);
72 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
73
74 rc = dcfg_seats_create(dcfg, &seats);
75 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
76
77 rc = dcfg_seats_insert(seats, "Alice", 42, &entry);
78 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
79 PCUT_ASSERT_NOT_NULL(entry);
80
81 PCUT_ASSERT_STR_EQUALS("Alice", entry->name);
82 PCUT_ASSERT_INT_EQUALS(42, entry->seat_id);
83
84 dcfg_seats_destroy(seats);
85 display_cfg_destroy(dcfg);
86}
87
88/** dcfg_seats_list_populate() populates seat list */
89PCUT_TEST(seats_list_populate)
90{
91 display_cfg_t *dcfg;
92 dcfg_seats_t *seats;
93 errno_t rc;
94 service_id_t sid;
95 test_response_t resp;
96 loc_srv_t *srv;
97
98 async_set_fallback_port_handler(test_dispcfg_conn, &resp);
99
100 // FIXME This causes this test to be non-reentrant!
101 rc = loc_server_register(test_dispcfg_server, &srv);
102 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
103
104 rc = loc_service_register(srv, test_dispcfg_svc, &sid);
105 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
106
107 rc = display_cfg_create(UI_DISPLAY_NULL, &dcfg);
108 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
109
110 rc = display_cfg_open(dcfg, test_dispcfg_svc);
111 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
112
113 rc = dcfg_seats_create(dcfg, &seats);
114 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
115
116 /*
117 * dcfg_seat_list_populate() calls dispcfg_get_seat_list()
118 * and dispcfg_get_seat_info()
119 */
120 resp.rc = EOK;
121 resp.get_seat_list_rlist = calloc(1, sizeof(dispcfg_seat_list_t));
122 PCUT_ASSERT_NOT_NULL(resp.get_seat_list_rlist);
123 resp.get_seat_list_rlist->nseats = 1;
124 resp.get_seat_list_rlist->seats = calloc(1, sizeof(sysarg_t));
125 PCUT_ASSERT_NOT_NULL(resp.get_seat_list_rlist->seats);
126 resp.get_seat_list_rlist->seats[0] = 42;
127
128 resp.get_seat_info_rinfo = calloc(1, sizeof(dispcfg_seat_info_t));
129 PCUT_ASSERT_NOT_NULL(resp.get_seat_info_rinfo);
130 resp.get_seat_info_rinfo->name = str_dup("Alice");
131 PCUT_ASSERT_NOT_NULL(resp.get_seat_info_rinfo->name);
132
133 rc = dcfg_seats_list_populate(seats);
134 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
135
136 dcfg_seats_destroy(seats);
137 display_cfg_destroy(dcfg);
138
139 rc = loc_service_unregister(srv, sid);
140 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
141 loc_server_unregister(srv);
142}
143
144/** dcfg_devices_insert() inserts an entry into the device list */
145PCUT_TEST(devices_insert)
146{
147 display_cfg_t *dcfg;
148 dcfg_seats_t *seats;
149 ui_list_entry_t *lentry;
150 dcfg_devices_entry_t *entry;
151 errno_t rc;
152
153 rc = display_cfg_create(UI_DISPLAY_NULL, &dcfg);
154 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
155
156 rc = dcfg_seats_create(dcfg, &seats);
157 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
158
159 rc = dcfg_devices_insert(seats, "mydevice", 42);
160 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
161
162 lentry = ui_list_first(seats->device_list);
163 PCUT_ASSERT_NOT_NULL(lentry);
164 entry = (dcfg_devices_entry_t *)ui_list_entry_get_arg(lentry);
165 PCUT_ASSERT_NOT_NULL(entry);
166
167 PCUT_ASSERT_STR_EQUALS("mydevice", entry->name);
168 PCUT_ASSERT_INT_EQUALS(42, entry->svc_id);
169
170 dcfg_seats_destroy(seats);
171 display_cfg_destroy(dcfg);
172}
173
174/** dcfg_avail_devices_insert() inserts entry into available devices list */
175PCUT_TEST(avail_devices_insert)
176{
177 display_cfg_t *dcfg;
178 dcfg_seats_t *seats;
179 ui_list_entry_t *lentry;
180 dcfg_devices_entry_t *entry;
181 ui_select_dialog_t *dialog;
182 ui_select_dialog_params_t sdparams;
183 errno_t rc;
184
185 rc = display_cfg_create(UI_DISPLAY_NULL, &dcfg);
186 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
187
188 rc = dcfg_seats_create(dcfg, &seats);
189 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
190
191 ui_select_dialog_params_init(&sdparams);
192 sdparams.caption = "Dialog";
193 sdparams.prompt = "Select";
194
195 rc = ui_select_dialog_create(seats->dcfg->ui, &sdparams, &dialog);
196 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
197
198 rc = dcfg_avail_devices_insert(seats, dialog, "mydevice", 42);
199 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
200
201 lentry = ui_list_first(ui_select_dialog_list(dialog));
202 PCUT_ASSERT_NOT_NULL(lentry);
203 entry = (dcfg_devices_entry_t *)ui_list_entry_get_arg(lentry);
204 PCUT_ASSERT_NOT_NULL(entry);
205
206 PCUT_ASSERT_STR_EQUALS("mydevice", entry->name);
207 PCUT_ASSERT_INT_EQUALS(42, entry->svc_id);
208
209 ui_select_dialog_destroy(dialog);
210 dcfg_seats_destroy(seats);
211 display_cfg_destroy(dcfg);
212}
213
214PCUT_TEST(asgn_dev_list_populate)
215{
216}
217
218PCUT_TEST(avail_dev_list_populate)
219{
220}
221
222PCUT_TEST(seats_get_selected)
223{
224}
225
226PCUT_TEST(devices_get_selected)
227{
228}
229
230PCUT_TEST(seats_list_selected)
231{
232}
233
234PCUT_TEST(add_seat_clicked)
235{
236}
237
238PCUT_TEST(remove_seat_clicked)
239{
240}
241
242PCUT_TEST(add_seat_dialog_bok)
243{
244}
245
246PCUT_TEST(add_seat_dialog_bcancel)
247{
248}
249
250PCUT_TEST(add_seat_dialog_close)
251{
252}
253
254PCUT_TEST(add_device_clicked)
255{
256}
257
258PCUT_TEST(remove_device_clicked)
259{
260}
261
262PCUT_TEST(add_device_dialog_bok)
263{
264}
265
266PCUT_TEST(add_device_dialog_bcancel)
267{
268}
269
270PCUT_TEST(add_device_dialog_close)
271{
272}
273
274PCUT_EXPORT(seats);
Note: See TracBrowser for help on using the repository browser.