Debian Codegraph @

src/libqmi-glib/test/test-generated.c

raw
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details:
12 *
13 * Copyright (C) 2014 Aleksander Morgado <[email protected]>
14 */
15
16 #include <config.h>
17 #include <libqmi-glib.h>
18
19 #include "test-fixture.h"
20
21 /*****************************************************************************/
22
23 static void
24 test_generated_core (TestFixture *fixture)
25 {
26 /* Noop */
27 }
28
29 /*****************************************************************************/
30 /* DMS Get IDs */
31
32 #if defined HAVE_QMI_MESSAGE_DMS_GET_IDS
33
34 static void
35 dms_get_ids_ready (QmiClientDms *client,
36 GAsyncResult *res,
37 TestFixture *fixture)
38 {
39 QmiMessageDmsGetIdsOutput *output;
40 GError *error = NULL;
41 gboolean st;
42 const gchar *str;
43
44 output = qmi_client_dms_get_ids_finish (client, res, &error);
45 g_assert_no_error (error);
46 g_assert (output);
47
48 st = qmi_message_dms_get_ids_output_get_result (output, &error);
49 g_assert_no_error (error);
50 g_assert (st);
51
52 /* [/dev/cdc-wdm3] Device IDs retrieved:
53 * ESN: '80997874'
54 * IMEI: '359225050039973'
55 * MEID: '35922505003997' */
56 st = qmi_message_dms_get_ids_output_get_esn (output, &str, &error);
57 g_assert_no_error (error);
58 g_assert (st);
59 g_assert_cmpstr (str, ==, "80997874");
60
61 st = qmi_message_dms_get_ids_output_get_imei (output, &str, &error);
62 g_assert_no_error (error);
63 g_assert (st);
64 g_assert_cmpstr (str, ==, "359225050039973");
65
66 st = qmi_message_dms_get_ids_output_get_meid (output, &str, &error);
67 g_assert_no_error (error);
68 g_assert (st);
69 g_assert_cmpstr (str, ==, "35922505003997");
70
71 qmi_message_dms_get_ids_output_unref (output);
72
73 test_fixture_loop_stop (fixture);
74 }
75
76 static void
77 test_generated_dms_get_ids (TestFixture *fixture)
78 {
79 guint8 expected[] = {
80 0x01,
81 0x0C, 0x00, 0x00, 0x02, 0x01,
82 0x00, 0xFF, 0xFF, 0x25, 0x00, 0x00, 0x00
83 };
84 guint8 response[] = {
85 0x01,
86 0x45, 0x00, 0x80, 0x02, 0x01,
87 0x02, 0xFF, 0xFF, 0x25, 0x00, 0x39, 0x00, 0x02,
88 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x01,
89 0x00, 0x42, 0x12, 0x0E, 0x00, 0x33, 0x35, 0x39,
90 0x32, 0x32, 0x35, 0x30, 0x35, 0x30, 0x30, 0x33,
91 0x39, 0x39, 0x37, 0x10, 0x08, 0x00, 0x38, 0x30,
92 0x39, 0x39, 0x37, 0x38, 0x37, 0x34, 0x11, 0x0F,
93 0x00, 0x33, 0x35, 0x39, 0x32, 0x32, 0x35, 0x30,
94 0x35, 0x30, 0x30, 0x33, 0x39, 0x39, 0x37, 0x33
95 };
96
97 test_port_context_set_command (fixture->ctx,
98 expected, G_N_ELEMENTS (expected),
99 response, G_N_ELEMENTS (response),
100 fixture->service_info[QMI_SERVICE_DMS].transaction_id++);
101
102 qmi_client_dms_get_ids (QMI_CLIENT_DMS (fixture->service_info[QMI_SERVICE_DMS].client), NULL, 3, NULL,
103 (GAsyncReadyCallback) dms_get_ids_ready,
104 fixture);
105 test_fixture_loop_run (fixture);
106 }
107
108 #endif /* HAVE_QMI_MESSAGE_DMS_GET_IDS */
109
110 /*****************************************************************************/
111 /* DMS UIM Get PIN Status */
112
113 #if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_PIN_STATUS
114
115 static void
116 dms_uim_get_pin_status_ready (QmiClientDms *client,
117 GAsyncResult *res,
118 TestFixture *fixture)
119 {
120 QmiMessageDmsUimGetPinStatusOutput *output;
121 GError *error = NULL;
122 gboolean st;
123 QmiDmsUimPinStatus current_status;
124 guint8 verify_retries_left;
125 guint8 unblock_retries_left;
126
127 output = qmi_client_dms_uim_get_pin_status_finish (client, res, &error);
128 g_assert_no_error (error);
129 g_assert (output);
130
131 st = qmi_message_dms_uim_get_pin_status_output_get_result (output, &error);
132 g_assert_no_error (error);
133 g_assert (st);
134
135 /* [/dev/cdc-wdm3] PIN1:
136 * Status: enabled-not-verified
137 * Verify: 3
138 * Unblock: 10
139 * [/dev/cdc-wdm3] PIN2:
140 * Status: enabled-not-verified
141 * Verify: 2
142 * Unblock: 10
143 */
144
145 st = (qmi_message_dms_uim_get_pin_status_output_get_pin1_status (
146 output,
147 &current_status,
148 &verify_retries_left,
149 &unblock_retries_left,
150 &error));
151 g_assert_no_error (error);
152 g_assert (st);
153 g_assert_cmpuint (current_status, ==, QMI_DMS_UIM_PIN_STATUS_ENABLED_NOT_VERIFIED);
154 g_assert_cmpuint (verify_retries_left, ==, 3);
155 g_assert_cmpuint (unblock_retries_left, ==, 10);
156
157 st = (qmi_message_dms_uim_get_pin_status_output_get_pin2_status (
158 output,
159 &current_status,
160 &verify_retries_left,
161 &unblock_retries_left,
162 &error));
163 g_assert_no_error (error);
164 g_assert (st);
165 g_assert_cmpuint (current_status, ==, QMI_DMS_UIM_PIN_STATUS_ENABLED_NOT_VERIFIED);
166 g_assert_cmpuint (verify_retries_left, ==, 2);
167 g_assert_cmpuint (unblock_retries_left, ==, 10);
168
169 qmi_message_dms_uim_get_pin_status_output_unref (output);
170
171 test_fixture_loop_stop (fixture);
172 }
173
174 static void
175 test_generated_dms_uim_get_pin_status (TestFixture *fixture)
176 {
177 guint8 expected[] = {
178 0x01,
179 0x0C, 0x00, 0x00, 0x02, 0x01,
180 0x00, 0xFF, 0xFF, 0x2B, 0x00, 0x00, 0x00
181 };
182 guint8 response[] = {
183 0x01,
184 0x1F, 0x00, 0x80, 0x02, 0x01,
185 0x02, 0xFF, 0xFF, 0x2B, 0x00, 0x13, 0x00, 0x02,
186 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x03,
187 0x00, 0x01, 0x02, 0x0A, 0x11, 0x03, 0x00, 0x01,
188 0x03, 0x0A
189 };
190
191 test_port_context_set_command (fixture->ctx,
192 expected, G_N_ELEMENTS (expected),
193 response, G_N_ELEMENTS (response),
194 fixture->service_info[QMI_SERVICE_DMS].transaction_id++);
195
196 qmi_client_dms_uim_get_pin_status (QMI_CLIENT_DMS (fixture->service_info[QMI_SERVICE_DMS].client), NULL, 3, NULL,
197 (GAsyncReadyCallback) dms_uim_get_pin_status_ready,
198 fixture);
199 test_fixture_loop_run (fixture);
200 }
201
202 #endif /* HAVE_QMI_MESSAGE_DMS_UIM_GET_PIN_STATUS */
203
204 /*****************************************************************************/
205 /* DMS UIM Verify PIN */
206
207 #if defined HAVE_QMI_MESSAGE_DMS_UIM_VERIFY_PIN
208
209 static void
210 dms_uim_verify_pin_ready (QmiClientDms *client,
211 GAsyncResult *res,
212 TestFixture *fixture)
213 {
214 QmiMessageDmsUimVerifyPinOutput *output;
215 GError *error = NULL;
216 gboolean st;
217
218 output = qmi_client_dms_uim_verify_pin_finish (client, res, &error);
219 g_assert_no_error (error);
220 g_assert (output);
221
222 st = qmi_message_dms_uim_verify_pin_output_get_result (output, &error);
223 g_assert_no_error (error);
224 g_assert (st);
225
226 qmi_message_dms_uim_verify_pin_output_unref (output);
227
228 test_fixture_loop_stop (fixture);
229 }
230
231 static void
232 test_generated_dms_uim_verify_pin (TestFixture *fixture)
233 {
234 QmiMessageDmsUimVerifyPinInput *input;
235 gboolean st;
236 GError *error = NULL;
237 guint8 expected[] = {
238 0x01,
239 0x15, 0x00, 0x00, 0x02, 0x01,
240 0x00, 0x01, 0x00, 0x28, 0x00, 0x09, 0x00, 0x01,
241 0x06, 0x00, 0x01, 0x04, 0x31, 0x32, 0x33, 0x34
242 };
243 guint8 response[] = {
244 0x01,
245 0x13, 0x00, 0x80, 0x02, 0x01,
246 0x02, 0xFF, 0xFF, 0x28, 0x00, 0x07, 0x00, 0x02,
247 0x04, 0x00, 0x00, 0x00, 0x00, 0x00
248 };
249
250 test_port_context_set_command (fixture->ctx,
251 expected, G_N_ELEMENTS (expected),
252 response, G_N_ELEMENTS (response),
253 fixture->service_info[QMI_SERVICE_DMS].transaction_id++);
254
255 input = qmi_message_dms_uim_verify_pin_input_new ();
256 st = qmi_message_dms_uim_verify_pin_input_set_info (input, QMI_DMS_UIM_PIN_ID_PIN, "1234", &error);
257 g_assert_no_error (error);
258 g_assert (st);
259
260 qmi_client_dms_uim_verify_pin (QMI_CLIENT_DMS (fixture->service_info[QMI_SERVICE_DMS].client), input, 3, NULL,
261 (GAsyncReadyCallback) dms_uim_verify_pin_ready,
262 fixture);
263
264 qmi_message_dms_uim_verify_pin_input_unref (input);
265
266 test_fixture_loop_run (fixture);
267 }
268
269 #endif /* HAVE_QMI_MESSAGE_DMS_UIM_VERIFY_PIN */
270
271 /*****************************************************************************/
272 /* DMS Get Time
273 *
274 * Note: the original device time in the real-life binary message used had the
275 * time source set to QMI_DMS_TIME_SOURCE_DEVICE. This value has been modified
276 * to explicitly make the 6-byte long uint read different from an 8-byte long
277 * read of the same buffer, as QMI_DMS_TIME_SOURCE_DEVICE is actually 0x0000.
278 */
279
280 #if defined HAVE_QMI_MESSAGE_DMS_GET_TIME
281
282 static void
283 dms_get_time_ready (QmiClientDms *client,
284 GAsyncResult *res,
285 TestFixture *fixture)
286 {
287 QmiMessageDmsGetTimeOutput *output;
288 GError *error = NULL;
289 gboolean st;
290 guint64 device_time_time_count;
291 QmiDmsTimeSource device_time_time_source;
292 guint64 system_time;
293 guint64 user_time;
294
295 output = qmi_client_dms_get_time_finish (client, res, &error);
296 g_assert_no_error (error);
297 g_assert (output);
298
299 st = qmi_message_dms_get_time_output_get_result (output, &error);
300 g_assert_no_error (error);
301 g_assert (st);
302
303 st = qmi_message_dms_get_time_output_get_device_time (output, &device_time_time_count, &device_time_time_source, &error);
304 g_assert_no_error (error);
305 g_assert (st);
306 g_assert_cmpuint (device_time_time_count, == , 884789480513ULL);
307 g_assert_cmpuint (device_time_time_source, ==, QMI_DMS_TIME_SOURCE_HDR_NETWORK);
308
309 st = qmi_message_dms_get_time_output_get_system_time (output, &system_time, &error);
310 g_assert_no_error (error);
311 g_assert (st);
312 g_assert_cmpuint (system_time, ==, 1105986850641ULL);
313
314 st = qmi_message_dms_get_time_output_get_user_time (output, &user_time, &error);
315 g_assert_no_error (error);
316 g_assert (st);
317 g_assert_cmpuint (user_time, ==, 11774664);
318
319 qmi_message_dms_get_time_output_unref (output);
320
321 test_fixture_loop_stop (fixture);
322 }
323
324 static void
325 test_generated_dms_get_time (TestFixture *fixture)
326 {
327 guint8 expected[] = {
328 0x01,
329 0x0C, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x00, 0x2F, 0x00,
330 0x00, 0x00
331 };
332 guint8 response[] = {
333 0x01,
334 0x34, 0x00, 0x80, 0x02, 0x01, 0x02, 0x01, 0x00, 0x2F, 0x00,
335 0x28, 0x00,
336 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
337 0x01, 0x08, 0x00, 0x41, 0x0C, 0x90, 0x01, 0xCE, 0x00, 0x02, 0x00, /* Note: last 0x0200 for HDR network source */
338 0x10, 0x08, 0x00, 0x51, 0x0F, 0xF4, 0x81, 0x01, 0x01, 0x00, 0x00,
339 0x11, 0x08, 0x00, 0xC8, 0xAA, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x00
340 };
341
342 test_port_context_set_command (fixture->ctx,
343 expected, G_N_ELEMENTS (expected),
344 response, G_N_ELEMENTS (response),
345 fixture->service_info[QMI_SERVICE_DMS].transaction_id++);
346
347 qmi_client_dms_get_time (QMI_CLIENT_DMS (fixture->service_info[QMI_SERVICE_DMS].client), NULL, 3, NULL,
348 (GAsyncReadyCallback) dms_get_time_ready,
349 fixture);
350
351 test_fixture_loop_run (fixture);
352 }
353
354 #endif /* HAVE_QMI_MESSAGE_DMS_GET_TIME */
355
356 /*****************************************************************************/
357 /* NAS Network Scan */
358
359 #if defined HAVE_QMI_MESSAGE_NAS_NETWORK_SCAN
360
361 typedef struct {
362 guint16 mcc;
363 guint16 mnc;
364 gboolean includes_pcs_digit;
365 QmiNasNetworkStatus network_status;
366 QmiNasRadioInterface rat;
367 const gchar *description;
368
369 } NetworkScanResult;
370
371 static NetworkScanResult scan_results[] = {
372 {
373 .mcc = 214,
374 .mnc = 1,
375 .includes_pcs_digit = FALSE,
376 .network_status = (QMI_NAS_NETWORK_STATUS_AVAILABLE |
377 QMI_NAS_NETWORK_STATUS_ROAMING |
378 QMI_NAS_NETWORK_STATUS_NOT_FORBIDDEN |
379 QMI_NAS_NETWORK_STATUS_NOT_PREFERRED),
380 .rat = QMI_NAS_RADIO_INTERFACE_GSM,
381 .description = "voda ES"
382 },
383 {
384 .mcc = 214,
385 .mnc = 3,
386 .includes_pcs_digit = FALSE,
387 .network_status = (QMI_NAS_NETWORK_STATUS_AVAILABLE |
388 QMI_NAS_NETWORK_STATUS_ROAMING |
389 QMI_NAS_NETWORK_STATUS_NOT_FORBIDDEN |
390 QMI_NAS_NETWORK_STATUS_NOT_PREFERRED),
391 .rat = QMI_NAS_RADIO_INTERFACE_GSM,
392 .description = "Orange"
393 },
394 {
395 .mcc = 214,
396 .mnc = 4,
397 .includes_pcs_digit = FALSE,
398 .network_status = (QMI_NAS_NETWORK_STATUS_AVAILABLE |
399 QMI_NAS_NETWORK_STATUS_ROAMING |
400 QMI_NAS_NETWORK_STATUS_NOT_FORBIDDEN |
401 QMI_NAS_NETWORK_STATUS_NOT_PREFERRED),
402 .rat = QMI_NAS_RADIO_INTERFACE_UMTS,
403 .description = "YOIGO"
404 },
405 {
406 .mcc = 214,
407 .mnc = 1,
408 .includes_pcs_digit = FALSE,
409 .network_status = (QMI_NAS_NETWORK_STATUS_AVAILABLE |
410 QMI_NAS_NETWORK_STATUS_ROAMING |
411 QMI_NAS_NETWORK_STATUS_NOT_FORBIDDEN |
412 QMI_NAS_NETWORK_STATUS_NOT_PREFERRED),
413 .rat = QMI_NAS_RADIO_INTERFACE_UMTS,
414 .description = "voda ES"
415 },
416 {
417 .mcc = 214,
418 .mnc = 4,
419 .includes_pcs_digit = FALSE,
420 .network_status = (QMI_NAS_NETWORK_STATUS_AVAILABLE |
421 QMI_NAS_NETWORK_STATUS_ROAMING |
422 QMI_NAS_NETWORK_STATUS_NOT_FORBIDDEN |
423 QMI_NAS_NETWORK_STATUS_NOT_PREFERRED),
424 .rat = QMI_NAS_RADIO_INTERFACE_GSM,
425 .description = "YOIGO"
426 },
427 {
428 .mcc = 214,
429 .mnc = 7,
430 .includes_pcs_digit = FALSE,
431 .network_status = (QMI_NAS_NETWORK_STATUS_AVAILABLE |
432 QMI_NAS_NETWORK_STATUS_ROAMING |
433 QMI_NAS_NETWORK_STATUS_NOT_FORBIDDEN |
434 QMI_NAS_NETWORK_STATUS_NOT_PREFERRED),
435 .rat = QMI_NAS_RADIO_INTERFACE_GSM,
436 .description = "Movistar"
437 },
438 {
439 .mcc = 214,
440 .mnc = 7,
441 .includes_pcs_digit = FALSE,
442 .network_status = (QMI_NAS_NETWORK_STATUS_AVAILABLE |
443 QMI_NAS_NETWORK_STATUS_ROAMING |
444 QMI_NAS_NETWORK_STATUS_NOT_FORBIDDEN |
445 QMI_NAS_NETWORK_STATUS_NOT_PREFERRED),
446 .rat = QMI_NAS_RADIO_INTERFACE_UMTS,
447 .description = "Movistar"
448 },
449 {
450 .mcc = 214,
451 .mnc = 3,
452 .includes_pcs_digit = FALSE,
453 .network_status = (QMI_NAS_NETWORK_STATUS_CURRENT_SERVING |
454 QMI_NAS_NETWORK_STATUS_ROAMING |
455 QMI_NAS_NETWORK_STATUS_NOT_FORBIDDEN |
456 QMI_NAS_NETWORK_STATUS_NOT_PREFERRED),
457 .rat = QMI_NAS_RADIO_INTERFACE_UMTS,
458 .description = ""
459 },
460 };
461
462 static void
463 nas_network_scan_ready (QmiClientNas *client,
464 GAsyncResult *res,
465 TestFixture *fixture)
466 {
467 QmiMessageNasNetworkScanOutput *output;
468 GError *error = NULL;
469 gboolean st;
470 GArray *network_information = NULL;
471 GPtrArray *network_information_ptr = NULL;
472 GArray *radio_access_technology = NULL;
473 GArray *mnc_pcs_digit_include_status = NULL;
474 guint i;
475
476 output = qmi_client_nas_network_scan_finish (client, res, &error);
477 g_assert_no_error (error);
478 g_assert (output);
479
480 st = qmi_message_nas_network_scan_output_get_result (output, &error);
481 g_assert_no_error (error);
482 g_assert (st);
483
484 st = (qmi_message_nas_network_scan_output_get_network_information (
485 output,
486 &network_information,
487 &error));
488 g_assert_no_error (error);
489 g_assert (st);
490 g_assert (network_information);
491 g_assert_cmpuint (network_information->len, ==, 8);
492 for (i = 0; i < network_information->len; i++) {
493 QmiMessageNasNetworkScanOutputNetworkInformationElement *el;
494
495 el = &g_array_index (network_information, QmiMessageNasNetworkScanOutputNetworkInformationElement, i);
496
497 g_assert_cmpuint (el->mcc, ==, scan_results[i].mcc);
498 g_assert_cmpuint (el->mnc, ==, scan_results[i].mnc);
499 g_assert_cmpuint (el->network_status, ==, scan_results[i].network_status);
500 g_assert_cmpstr (el->description, ==, scan_results[i].description);
501 }
502
503 /* GIR compat method with GPtrArray */
504 st = (qmi_message_nas_network_scan_output_get_network_information_gir (
505 output,
506 &network_information_ptr,
507 &error));
508 g_assert_no_error (error);
509 g_assert (st);
510 g_assert (network_information_ptr);
511 g_assert_cmpuint (network_information_ptr->len, ==, 8);
512 for (i = 0; i < network_information_ptr->len; i++) {
513 QmiMessageNasNetworkScanOutputNetworkInformationElement *el;
514
515 el = g_ptr_array_index (network_information_ptr, i);
516
517 g_assert_cmpuint (el->mcc, ==, scan_results[i].mcc);
518 g_assert_cmpuint (el->mnc, ==, scan_results[i].mnc);
519 g_assert_cmpuint (el->network_status, ==, scan_results[i].network_status);
520 g_assert_cmpstr (el->description, ==, scan_results[i].description);
521 }
522
523 st = (qmi_message_nas_network_scan_output_get_radio_access_technology (
524 output,
525 &radio_access_technology,
526 &error));
527 g_assert_no_error (error);
528 g_assert (st);
529 g_assert (radio_access_technology);
530 g_assert_cmpuint (radio_access_technology->len, ==, 8);
531 for (i = 0; i < radio_access_technology->len; i++) {
532 QmiMessageNasNetworkScanOutputRadioAccessTechnologyElement *el;
533
534 el = &g_array_index (radio_access_technology, QmiMessageNasNetworkScanOutputRadioAccessTechnologyElement, i);
535
536 g_assert_cmpuint (el->mcc, ==, scan_results[i].mcc);
537 g_assert_cmpuint (el->mnc, ==, scan_results[i].mnc);
538 g_assert_cmpuint (el->radio_interface, ==, scan_results[i].rat);
539 }
540
541 st = (qmi_message_nas_network_scan_output_get_mnc_pcs_digit_include_status (
542 output,
543 &mnc_pcs_digit_include_status,
544 &error));
545 g_assert_no_error (error);
546 g_assert (st);
547 g_assert (mnc_pcs_digit_include_status);
548 g_assert_cmpuint (mnc_pcs_digit_include_status->len, ==, 8);
549 for (i = 0; i < mnc_pcs_digit_include_status->len; i++) {
550 QmiMessageNasNetworkScanOutputMncPcsDigitIncludeStatusElement *el;
551
552 el = &g_array_index (mnc_pcs_digit_include_status, QmiMessageNasNetworkScanOutputMncPcsDigitIncludeStatusElement, i);
553
554 g_assert_cmpuint (el->mcc, ==, scan_results[i].mcc);
555 g_assert_cmpuint (el->mnc, ==, scan_results[i].mnc);
556 g_assert_cmpuint (el->includes_pcs_digit, ==, scan_results[i].includes_pcs_digit);
557 }
558
559 qmi_message_nas_network_scan_output_unref (output);
560
561 test_fixture_loop_stop (fixture);
562 }
563
564 static void
565 test_generated_nas_network_scan (TestFixture *fixture)
566 {
567 guint8 expected[] = {
568 0x01,
569 0x0C, 0x00, 0x00, 0x03, 0x01,
570 0x00, 0xFF, 0xFF, 0x21, 0x00, 0x00, 0x00
571 };
572 guint8 response[] = {
573 0x01,
574 0x43, 0x01, 0x80, 0x03, 0x01,
575 0x02, 0xFF, 0xFF, 0x21, 0x00, 0x37, 0x01, 0x02,
576 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x60,
577 0x00, 0x08, 0x00, 0xD6, 0x00, 0x01, 0x00, 0xAA,
578 0x07, 0x76, 0x6F, 0x64, 0x61, 0x20, 0x45, 0x53,
579 0xD6, 0x00, 0x03, 0x00, 0xAA, 0x06, 0x4F, 0x72,
580 0x61, 0x6E, 0x67, 0x65, 0xD6, 0x00, 0x04, 0x00,
581 0xAA, 0x05, 0x59, 0x4F, 0x49, 0x47, 0x4F, 0xD6,
582 0x00, 0x01, 0x00, 0xAA, 0x07, 0x76, 0x6F, 0x64,
583 0x61, 0x20, 0x45, 0x53, 0xD6, 0x00, 0x04, 0x00,
584 0xAA, 0x05, 0x59, 0x4F, 0x49, 0x47, 0x4F, 0xD6,
585 0x00, 0x07, 0x00, 0xAA, 0x08, 0x4D, 0x6F, 0x76,
586 0x69, 0x73, 0x74, 0x61, 0x72, 0xD6, 0x00, 0x07,
587 0x00, 0xAA, 0x08, 0x4D, 0x6F, 0x76, 0x69, 0x73,
588 0x74, 0x61, 0x72, 0xD6, 0x00, 0x03, 0x00, 0xA9,
589 0x00, 0x11, 0x2A, 0x00, 0x08, 0x00, 0xD6, 0x00,
590 0x01, 0x00, 0x04, 0xD6, 0x00, 0x03, 0x00, 0x04,
591 0xD6, 0x00, 0x04, 0x00, 0x05, 0xD6, 0x00, 0x01,
592 0x00, 0x05, 0xD6, 0x00, 0x04, 0x00, 0x04, 0xD6,
593 0x00, 0x07, 0x00, 0x04, 0xD6, 0x00, 0x07, 0x00,
594 0x05, 0xD6, 0x00, 0x03, 0x00, 0x05, 0x12, 0x2A,
595 0x00, 0x08, 0x00, 0xD6, 0x00, 0x01, 0x00, 0x00,
596 0xD6, 0x00, 0x03, 0x00, 0x00, 0xD6, 0x00, 0x04,
597 0x00, 0x00, 0xD6, 0x00, 0x01, 0x00, 0x00, 0xD6,
598 0x00, 0x04, 0x00, 0x00, 0xD6, 0x00, 0x07, 0x00,
599 0x00, 0xD6, 0x00, 0x07, 0x00, 0x00, 0xD6, 0x00,
600 0x03, 0x00, 0x00, 0x13, 0x04, 0x00, 0x00, 0x00,
601 0x00, 0x00, 0x14, 0x69, 0x00, 0x08, 0xD6, 0x00,
602 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
603 0x00, 0x00, 0x00, 0xD6, 0x00, 0x03, 0x00, 0x00,
604 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
605 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
606 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
607 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
608 0x00, 0x00, 0xD6, 0x00, 0x04, 0x00, 0x00, 0x00,
609 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD6,
610 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
611 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
612 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
613 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
614 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
615 };
616
617 test_port_context_set_command (fixture->ctx,
618 expected, G_N_ELEMENTS (expected),
619 response, G_N_ELEMENTS (response),
620 fixture->service_info[QMI_SERVICE_NAS].transaction_id++);
621
622 qmi_client_nas_network_scan (QMI_CLIENT_NAS (fixture->service_info[QMI_SERVICE_NAS].client), NULL, 3, NULL,
623 (GAsyncReadyCallback) nas_network_scan_ready,
624 fixture);
625
626 test_fixture_loop_run (fixture);
627 }
628
629 #endif /* HAVE_QMI_MESSAGE_NAS_NETWORK_SCAN */
630
631 /*****************************************************************************/
632 /* NAS Get Cell Location */
633
634 #if defined HAVE_QMI_MESSAGE_NAS_GET_CELL_LOCATION_INFO
635
636 static void
637 nas_get_cell_location_info_1_ready (QmiClientNas *client,
638 GAsyncResult *res,
639 TestFixture *fixture)
640 {
641 QmiMessageNasGetCellLocationInfoOutput *output;
642 GError *error = NULL;
643 gboolean st;
644
645 output = qmi_client_nas_get_cell_location_info_finish (client, res, &error);
646 g_assert_no_error (error);
647 g_assert (output);
648
649 st = qmi_message_nas_get_cell_location_info_output_get_result (output, &error);
650 g_assert_no_error (error);
651 g_assert (st);
652
653 qmi_message_nas_get_cell_location_info_output_unref (output);
654
655 test_fixture_loop_stop (fixture);
656 }
657
658 static void
659 test_generated_nas_get_cell_location_info_1 (TestFixture *fixture)
660 {
661 guint8 expected[] = {
662 0x01,
663 0x0C, 0x00, 0x00, 0x03, 0x01,
664 0x00, 0x01, 0x00, 0x43, 0x00, 0x00, 0x00
665 };
666 guint8 response[] = {
667 0x01,
668 0x53, 0x00, 0x80, 0x03, 0x01,
669 0x02, 0x01, 0x00, 0x43, 0x00, 0x47, 0x00, 0x02,
670 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x3D,
671 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
672 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
673 0xFF, 0x28, 0x00, 0x03, 0x7D, 0x6F, 0x00, 0x00,
674 0x32, 0xF4, 0x51, 0xB3, 0x00, 0x4D, 0x00, 0x11,
675 0x2A, 0x00, 0x8A, 0x3C, 0x00, 0x00, 0x32, 0xF4,
676 0x51, 0xB3, 0x00, 0x63, 0x00, 0x30, 0x14, 0x00,
677 0x89, 0x3C, 0x00, 0x00, 0x32, 0xF4, 0x51, 0xB3,
678 0x00, 0x59, 0x00, 0x11, 0x0D, 0x00
679 };
680
681 test_port_context_set_command (fixture->ctx,
682 expected, G_N_ELEMENTS (expected),
683 response, G_N_ELEMENTS (response),
684 fixture->service_info[QMI_SERVICE_NAS].transaction_id++);
685
686 qmi_client_nas_get_cell_location_info (QMI_CLIENT_NAS (fixture->service_info[QMI_SERVICE_NAS].client), NULL, 3, NULL,
687 (GAsyncReadyCallback) nas_get_cell_location_info_1_ready,
688 fixture);
689
690 test_fixture_loop_run (fixture);
691 }
692
693 static void
694 nas_get_cell_location_info_2_ready (QmiClientNas *client,
695 GAsyncResult *res,
696 TestFixture *fixture)
697 {
698 QmiMessageNasGetCellLocationInfoOutput *output;
699 GError *error = NULL;
700 gboolean st;
701
702 output = qmi_client_nas_get_cell_location_info_finish (client, res, &error);
703 g_assert_no_error (error);
704 g_assert (output);
705
706 st = qmi_message_nas_get_cell_location_info_output_get_result (output, &error);
707 g_assert_no_error (error);
708 g_assert (st);
709
710 {
711 gboolean value_intrafrequency_lte_info_ue_in_idle = FALSE;
712 GArray *value_intrafrequency_lte_info_plmn = NULL;
713 guint16 value_intrafrequency_lte_info_tracking_area_code = 0;
714 guint32 value_intrafrequency_lte_info_global_cell_id = 0;
715 guint16 value_intrafrequency_lte_info_eutra_absolute_rf_channel_number = 0;
716 guint16 value_intrafrequency_lte_info_serving_cell_id = 0;
717 guint8 value_intrafrequency_lte_info_cell_reselection_priority = 0;
718 guint8 value_intrafrequency_lte_info_s_non_intra_search_threshold = 0;
719 guint8 value_intrafrequency_lte_info_serving_cell_low_threshold = 0;
720 guint8 value_intrafrequency_lte_info_s_intra_search_threshold = 0;
721 GArray *value_intrafrequency_lte_info_cell = NULL;
722
723 gboolean value_intrafrequency_lte_info_ue_in_idle_gir = FALSE;
724 GArray *value_intrafrequency_lte_info_plmn_gir = NULL;
725 guint16 value_intrafrequency_lte_info_tracking_area_code_gir = 0;
726 guint32 value_intrafrequency_lte_info_global_cell_id_gir = 0;
727 guint16 value_intrafrequency_lte_info_eutra_absolute_rf_channel_number_gir = 0;
728 guint16 value_intrafrequency_lte_info_serving_cell_id_gir = 0;
729 guint8 value_intrafrequency_lte_info_cell_reselection_priority_gir = 0;
730 guint8 value_intrafrequency_lte_info_s_non_intra_search_threshold_gir = 0;
731 guint8 value_intrafrequency_lte_info_serving_cell_low_threshold_gir = 0;
732 guint8 value_intrafrequency_lte_info_s_intra_search_threshold_gir = 0;
733 GPtrArray *value_intrafrequency_lte_info_cell_gir = NULL;
734
735 guint i;
736
737 st = qmi_message_nas_get_cell_location_info_output_get_intrafrequency_lte_info_v2 (output,
738 &value_intrafrequency_lte_info_ue_in_idle,
739 &value_intrafrequency_lte_info_plmn,
740 &value_intrafrequency_lte_info_tracking_area_code,
741 &value_intrafrequency_lte_info_global_cell_id,
742 &value_intrafrequency_lte_info_eutra_absolute_rf_channel_number,
743 &value_intrafrequency_lte_info_serving_cell_id,
744 &value_intrafrequency_lte_info_cell_reselection_priority,
745 &value_intrafrequency_lte_info_s_non_intra_search_threshold,
746 &value_intrafrequency_lte_info_serving_cell_low_threshold,
747 &value_intrafrequency_lte_info_s_intra_search_threshold,
748 &value_intrafrequency_lte_info_cell,
749 &error);
750 g_assert_no_error (error);
751 g_assert (st);
752
753 st = qmi_message_nas_get_cell_location_info_output_get_intrafrequency_lte_info_v2_gir (output,
754 &value_intrafrequency_lte_info_ue_in_idle_gir,
755 &value_intrafrequency_lte_info_plmn_gir,
756 &value_intrafrequency_lte_info_tracking_area_code_gir,
757 &value_intrafrequency_lte_info_global_cell_id_gir,
758 &value_intrafrequency_lte_info_eutra_absolute_rf_channel_number_gir,
759 &value_intrafrequency_lte_info_serving_cell_id_gir,
760 &value_intrafrequency_lte_info_cell_reselection_priority_gir,
761 &value_intrafrequency_lte_info_s_non_intra_search_threshold_gir,
762 &value_intrafrequency_lte_info_serving_cell_low_threshold_gir,
763 &value_intrafrequency_lte_info_s_intra_search_threshold_gir,
764 &value_intrafrequency_lte_info_cell_gir,
765 &error);
766 g_assert_no_error (error);
767 g_assert (st);
768
769 g_assert_cmpuint (value_intrafrequency_lte_info_ue_in_idle, ==, value_intrafrequency_lte_info_ue_in_idle_gir);
770 g_assert_cmpuint (value_intrafrequency_lte_info_plmn->len, ==, value_intrafrequency_lte_info_plmn_gir->len);
771 for (i = 0; i < value_intrafrequency_lte_info_plmn->len; i++)
772 g_assert_cmpuint (g_array_index (value_intrafrequency_lte_info_plmn, guint8, i), ==, g_array_index (value_intrafrequency_lte_info_plmn_gir, guint8, i));
773 g_assert_cmpuint (value_intrafrequency_lte_info_tracking_area_code, ==, value_intrafrequency_lte_info_tracking_area_code_gir);
774 g_assert_cmpuint (value_intrafrequency_lte_info_global_cell_id, == , value_intrafrequency_lte_info_global_cell_id_gir);
775 g_assert_cmpuint (value_intrafrequency_lte_info_eutra_absolute_rf_channel_number, == , value_intrafrequency_lte_info_eutra_absolute_rf_channel_number_gir);
776 g_assert_cmpuint (value_intrafrequency_lte_info_serving_cell_id, == , value_intrafrequency_lte_info_serving_cell_id_gir);
777 g_assert_cmpuint (value_intrafrequency_lte_info_cell_reselection_priority, == , value_intrafrequency_lte_info_cell_reselection_priority_gir);
778 g_assert_cmpuint (value_intrafrequency_lte_info_s_non_intra_search_threshold, == , value_intrafrequency_lte_info_s_non_intra_search_threshold_gir);
779 g_assert_cmpuint (value_intrafrequency_lte_info_serving_cell_low_threshold, == , value_intrafrequency_lte_info_serving_cell_low_threshold_gir);
780 g_assert_cmpuint (value_intrafrequency_lte_info_s_intra_search_threshold, == , value_intrafrequency_lte_info_s_intra_search_threshold_gir);
781 g_assert_cmpuint (value_intrafrequency_lte_info_cell->len, ==, value_intrafrequency_lte_info_cell_gir->len);
782 for (i = 0; i < value_intrafrequency_lte_info_cell->len; i++) {
783 QmiMessageNasGetCellLocationInfoOutputIntrafrequencyLteInfoV2CellElement *cell;
784 QmiMessageNasGetCellLocationInfoOutputIntrafrequencyLteInfoV2CellElement *cell_gir;
785
786 cell = &g_array_index (value_intrafrequency_lte_info_cell, QmiMessageNasGetCellLocationInfoOutputIntrafrequencyLteInfoV2CellElement, i);
787 cell_gir = g_ptr_array_index (value_intrafrequency_lte_info_cell_gir, i);
788 g_assert_cmpuint (cell->physical_cell_id, ==, cell_gir->physical_cell_id);
789 g_assert_cmpuint (cell->rsrq, ==, cell_gir->rsrq);
790 g_assert_cmpuint (cell->rsrp, ==, cell_gir->rsrp);
791 g_assert_cmpuint (cell->rssi, ==, cell_gir->rssi);
792 g_assert_cmpuint (cell->cell_selection_rx_level, ==, cell_gir->cell_selection_rx_level);
793 }
794 }
795
796 qmi_message_nas_get_cell_location_info_output_unref (output);
797
798 test_fixture_loop_stop (fixture);
799 }
800
801 static void
802 test_generated_nas_get_cell_location_info_2 (TestFixture *fixture)
803 {
804 guint8 expected[] = {
805 0x01,
806 0x0C, 0x00, 0x00, 0x03,
807 0x01, 0x00, 0x01, 0x00, 0x43, 0x00, 0x00, 0x00,
808 };
809 guint8 response[] = {
810 0x01,
811 0x67, 0x00, 0x80, 0x03, 0x01,
812 0x02, 0x01, 0x00, 0x43, 0x00, 0x5B, 0x00, 0x02,
813 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
814 0x13, 0x1D, 0x00,
815 0x01, 0x99, 0xF9, 0x04, 0x99, 0x00, 0x01,
816 0xC2, 0x01, 0x00, 0x7E, 0xA9, 0x00, 0x00, 0x01,
817 0x3E, 0x28, 0x3E, 0x01, 0x00, 0x00, 0xBD, 0xFF,
818 0x19, 0xFC, 0x23, 0xFD, 0x1E, 0x00,
819 0x14, 0x02, 0x00,
820 0x01, 0x00,
821 0x15, 0x02, 0x00,
822 0x01, 0x00,
823 0x16, 0x02, 0x00,
824 0x01, 0x00,
825 0x1E, 0x04, 0x00,
826 0xFF, 0xFF, 0xFF, 0xFF,
827 0x26, 0x02, 0x00,
828 0x46, 0x00,
829 0x27, 0x04, 0x00,
830 0x7E, 0xA9, 0x00, 0x00,
831 0x28, 0x01, 0x00,
832 0x00,
833 0x2A, 0x04, 0x00,
834 0x03, 0x00, 0x00, 0x00,
835 0x2C, 0x04, 0x00,
836 0x00, 0x00, 0x00, 0x00
837 };
838
839 test_port_context_set_command (fixture->ctx,
840 expected, G_N_ELEMENTS (expected),
841 response, G_N_ELEMENTS (response),
842 fixture->service_info[QMI_SERVICE_NAS].transaction_id++);
843
844 qmi_client_nas_get_cell_location_info (QMI_CLIENT_NAS (fixture->service_info[QMI_SERVICE_NAS].client), NULL, 3, NULL,
845 (GAsyncReadyCallback) nas_get_cell_location_info_2_ready,
846 fixture);
847
848 test_fixture_loop_run (fixture);
849 }
850
851 static void
852 nas_get_cell_location_info_invalid_ready (QmiClientNas *client,
853 GAsyncResult *res,
854 TestFixture *fixture)
855 {
856 QmiMessageNasGetCellLocationInfoOutput *output;
857 g_autoptr(GError) error = NULL;
858
859 output = qmi_client_nas_get_cell_location_info_finish (client, res, &error);
860 g_assert_error (error, QMI_CORE_ERROR, QMI_CORE_ERROR_UNEXPECTED_MESSAGE);
861 g_assert (!output);
862
863 test_fixture_loop_stop (fixture);
864 }
865
866 static void
867 test_generated_nas_get_cell_location_info_invalid (TestFixture *fixture)
868 {
869 guint8 expected[] = {
870 0x01,
871 0x0C, 0x00, 0x00, 0x03, 0x01,
872 0x00, 0x01, 0x00, 0x43, 0x00, 0x00, 0x00
873 };
874 guint8 response[] = {
875 0x01,
876 0x53, 0x00, 0x80, 0x03, 0x01,
877 0x02, 0x01, 0x00, 0x44, 0x00, 0x47, 0x00, 0x02, /* command id set to 0x0044 instead of 0x0043 */
878 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x3D,
879 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
880 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
881 0xFF, 0x28, 0x00, 0x03, 0x7D, 0x6F, 0x00, 0x00,
882 0x32, 0xF4, 0x51, 0xB3, 0x00, 0x4D, 0x00, 0x11,
883 0x2A, 0x00, 0x8A, 0x3C, 0x00, 0x00, 0x32, 0xF4,
884 0x51, 0xB3, 0x00, 0x63, 0x00, 0x30, 0x14, 0x00,
885 0x89, 0x3C, 0x00, 0x00, 0x32, 0xF4, 0x51, 0xB3,
886 0x00, 0x59, 0x00, 0x11, 0x0D, 0x00
887 };
888
889 test_port_context_set_command (fixture->ctx,
890 expected, G_N_ELEMENTS (expected),
891 response, G_N_ELEMENTS (response),
892 fixture->service_info[QMI_SERVICE_NAS].transaction_id++);
893
894 qmi_client_nas_get_cell_location_info (QMI_CLIENT_NAS (fixture->service_info[QMI_SERVICE_NAS].client), NULL, 3, NULL,
895 (GAsyncReadyCallback) nas_get_cell_location_info_invalid_ready,
896 fixture);
897
898 test_fixture_loop_run (fixture);
899 }
900
901 static void
902 test_compat_nas_get_cell_location_info_geran_info_ready (QmiClientNas *client,
903 GAsyncResult *res,
904 TestFixture *fixture)
905 {
906 QmiMessageNasGetCellLocationInfoOutput *output;
907 GError *error = NULL;
908 gboolean st;
909
910 output = qmi_client_nas_get_cell_location_info_finish (client, res, &error);
911 g_assert_no_error (error);
912 g_assert (output);
913
914 st = qmi_message_nas_get_cell_location_info_output_get_result (output, &error);
915 g_assert_no_error (error);
916 g_assert (st);
917
918 {
919 guint32 geran_info_v2_cell_id = 0;
920 GArray *geran_info_v2_plmn = NULL;
921 guint16 geran_info_v2_lac = 0;
922 guint16 geran_info_v2_geran_absolute_rf_channel_number = 0;
923 guint8 geran_info_v2_base_station_identity_code = 0;
924 guint32 geran_info_v2_timing_advance = 0;
925 guint16 geran_info_v2_rx_level = 0;
926 GArray *geran_info_v2_cell = NULL;
927
928 st = qmi_message_nas_get_cell_location_info_output_get_geran_info_v2 (output,
929 &geran_info_v2_cell_id,
930 &geran_info_v2_plmn,
931 &geran_info_v2_lac,
932 &geran_info_v2_geran_absolute_rf_channel_number,
933 &geran_info_v2_base_station_identity_code,
934 &geran_info_v2_timing_advance,
935 &geran_info_v2_rx_level,
936 &geran_info_v2_cell,
937 &error);
938 g_assert_no_error (error);
939 g_assert (st);
940
941 #ifndef QMI_DISABLE_DEPRECATED
942 {
943 guint i;
944 guint32 geran_info_cell_id = 0;
945 const gchar *geran_info_plmn = NULL;
946 guint16 geran_info_lac = 0;
947 guint16 geran_info_geran_absolute_rf_channel_number = 0;
948 guint8 geran_info_base_station_identity_code = 0;
949 guint32 geran_info_timing_advance = 0;
950 guint16 geran_info_rx_level = 0;
951 GArray *geran_info_cell = NULL;
952
953 st = qmi_message_nas_get_cell_location_info_output_get_geran_info (output,
954 &geran_info_cell_id,
955 &geran_info_plmn,
956 &geran_info_lac,
957 &geran_info_geran_absolute_rf_channel_number,
958 &geran_info_base_station_identity_code,
959 &geran_info_timing_advance,
960 &geran_info_rx_level,
961 &geran_info_cell,
962 &error);
963 g_assert_no_error (error);
964 g_assert (st);
965
966 g_assert_cmpuint (geran_info_v2_cell_id, ==, geran_info_cell_id);
967 /* plmn won't be equal, as it's broken in v1 */
968 g_assert_cmpuint (geran_info_v2_lac, ==, geran_info_lac);
969 g_assert_cmpuint (geran_info_v2_geran_absolute_rf_channel_number, ==, geran_info_geran_absolute_rf_channel_number);
970 g_assert_cmpuint (geran_info_v2_base_station_identity_code, ==, geran_info_base_station_identity_code);
971 g_assert_cmpuint (geran_info_v2_timing_advance, ==, geran_info_timing_advance);
972 g_assert_cmpuint (geran_info_v2_rx_level, ==, geran_info_rx_level);
973
974 g_assert (geran_info_cell);
975 g_assert_cmpuint (geran_info_cell->len, ==, geran_info_v2_cell->len);
976 for (i = 0; i < geran_info_v2_cell->len; i++) {
977 QmiMessageNasGetCellLocationInfoOutputGeranInfoV2CellElement *elemv2;
978 QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement *elem;
979
980 elemv2 = &g_array_index (geran_info_v2_cell, QmiMessageNasGetCellLocationInfoOutputGeranInfoV2CellElement, i);
981 elem = &g_array_index (geran_info_cell, QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement, i);
982 g_assert_cmpuint (elem->cell_id, ==, elemv2->cell_id);
983 /* plmn won't be equal, as it's broken in v1 */
984 g_assert_cmpuint (elem->lac, ==, elemv2->lac);
985 g_assert_cmpuint (elem->geran_absolute_rf_channel_number, ==, elemv2->geran_absolute_rf_channel_number);
986 g_assert_cmpuint (elem->base_station_identity_code, ==, elemv2->base_station_identity_code);
987 g_assert_cmpuint (elem->rx_level, ==, elemv2->rx_level);
988 }
989 }
990 #endif /* QMI_DISABLE_DEPRECATED */
991 }
992
993 qmi_message_nas_get_cell_location_info_output_unref (output);
994
995 test_fixture_loop_stop (fixture);
996 }
997
998 static void
999 test_compat_nas_get_cell_location_info_geran_info (TestFixture *fixture)
1000 {
1001 guint8 request[] = {
1002 0x01, 0x0C, 0x00, 0x00, 0x03, 0x01, 0x00, 0x01,
1003 0x00, 0x43, 0x00, 0x00, 0x00
1004 };
1005 guint8 response[] = {
1006 0x01, 0x58, 0x01, 0x80, 0x03, 0x01, 0x02, 0x01,
1007 0x00, 0x43, 0x00, 0x4C, 0x01, 0x02, 0x04, 0x00,
1008 0x00, 0x00, 0x00, 0x00, 0x10, 0x67, 0x00, 0x02,
1009 0x09, 0x00, 0x00, 0x12, 0xF4, 0x30, 0x76, 0x04,
1010 0xDD, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32,
1011 0x00, 0x06, 0x8E, 0x08, 0x00, 0x00, 0x12, 0xF4,
1012 0x30, 0x76, 0x04, 0xD0, 0x03, 0x28, 0x28, 0x00,
1013 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
1014 0x00, 0xD6, 0x03, 0x0B, 0x1C, 0x00, 0xFF, 0xFF,
1015 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5,
1016 0x03, 0x24, 0x1A, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
1017 0x00, 0x00, 0x00, 0x00, 0x00, 0xD7, 0x03, 0x01,
1018 0x18, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
1019 0x00, 0x00, 0x00, 0xDF, 0x03, 0x22, 0x17, 0x00,
1020 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
1021 0x00, 0xDA, 0x03, 0x08, 0x10, 0x00, 0x1B, 0x04,
1022 0x00, 0xFF, 0xFF, 0xDD, 0x03, 0x21, 0xC7, 0x00,
1023 0x02, 0x09, 0x00, 0x00, 0x12, 0xF4, 0x30, 0x76,
1024 0x04, 0xDD, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
1025 0x32, 0x00, 0x06, 0x8E, 0x08, 0x00, 0x00, 0x12,
1026 0xF4, 0x30, 0x76, 0x04, 0xD0, 0x03, 0x28, 0x28,
1027 0x00, 0x24, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00,
1028 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1029 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
1030 0x00, 0x00, 0xD6, 0x03, 0x0B, 0x1C, 0x00, 0x00,
1031 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1032 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
1033 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
1034 0xD5, 0x03, 0x24, 0x1A, 0x00, 0x00, 0x00, 0x00,
1035 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1036 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
1037 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD7, 0x03,
1038 0x01, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1039 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1040 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
1041 0x00, 0x00, 0x00, 0x00, 0xDF, 0x03, 0x22, 0x17,
1042 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1043 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1044 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
1045 0x00, 0x00, 0xDA, 0x03, 0x08, 0x10, 0x00, 0x00,
1046 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1047 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24,
1048 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x25, 0x01, 0x00,
1049 0x00
1050 };
1051
1052 test_port_context_set_command (fixture->ctx,
1053 request, G_N_ELEMENTS (request),
1054 response, G_N_ELEMENTS (response),
1055 fixture->service_info[QMI_SERVICE_NAS].transaction_id++);
1056
1057 qmi_client_nas_get_cell_location_info (QMI_CLIENT_NAS (fixture->service_info[QMI_SERVICE_NAS].client), NULL, 3, NULL,
1058 (GAsyncReadyCallback) test_compat_nas_get_cell_location_info_geran_info_ready,
1059 fixture);
1060
1061 test_fixture_loop_run (fixture);
1062 }
1063
1064 #endif /* HAVE_QMI_MESSAGE_NAS_GET_CELL_LOCATION_INFO */
1065
1066 /*****************************************************************************/
1067 /* NAS Get Serving System */
1068
1069 #if defined HAVE_QMI_MESSAGE_NAS_GET_SERVING_SYSTEM
1070
1071 static void
1072 nas_get_serving_system_ready (QmiClientNas *client,
1073 GAsyncResult *res,
1074 TestFixture *fixture)
1075 {
1076 QmiMessageNasGetServingSystemOutput *output;
1077 GError *error = NULL;
1078 gboolean st;
1079
1080 output = qmi_client_nas_get_serving_system_finish (client, res, &error);
1081 g_assert_no_error (error);
1082 g_assert (output);
1083
1084 st = qmi_message_nas_get_serving_system_output_get_result (output, &error);
1085 g_assert_no_error (error);
1086 g_assert (st);
1087
1088 /* current plmn in GSM-7 instead of UTF-8:
1089 * <<<<<< TLV:
1090 * <<<<<< type = "Current PLMN" (0x12)
1091 * <<<<<< length = 10
1092 * <<<<<< value = DE:00:32:00:05:49:76:3A:4C:06
1093 * <<<<<< translated = [ mcc = '222' mnc = '50' description = 'Iliad' ]
1094 */
1095 {
1096 guint16 mcc;
1097 guint16 mnc;
1098 const gchar *description;
1099
1100 g_assert (qmi_message_nas_get_serving_system_output_get_current_plmn (output, &mcc, &mnc, &description, &error));
1101 g_assert_no_error (error);
1102 g_assert_cmpuint (mcc, ==, 222);
1103 g_assert_cmpuint (mnc, ==, 50);
1104 g_assert_cmpstr (description, ==, "Iliad");
1105 }
1106
1107 qmi_message_nas_get_serving_system_output_unref (output);
1108
1109 test_fixture_loop_stop (fixture);
1110 }
1111
1112 static void
1113 test_generated_nas_get_serving_system (TestFixture *fixture)
1114 {
1115 guint8 expected[] = {
1116 0x01,
1117 0x0C, 0x00, 0x00, 0x03, 0x01,
1118 0x00, 0x01, 0x00, 0x24, 0x00, 0x00, 0x00
1119 };
1120 guint8 response[] = {
1121 0x01,
1122 0x6E, 0x00, 0x80, 0x03, 0x01,
1123 0x02, 0x01, 0x00, 0x24, 0x00, 0x62, 0x00, 0x02,
1124 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06,
1125 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x05, 0x10,
1126 0x01, 0x00, 0x01, 0x11, 0x04, 0x00, 0x03, 0x03,
1127 0x04, 0x05, 0x12, 0x0A, 0x00, 0xDE, 0x00, 0x32,
1128 0x00, 0x05, 0x49, 0x76, 0x3A, 0x4C, 0x06, 0x15,
1129 0x03, 0x00, 0x01, 0x05, 0x01, 0x1B, 0x01, 0x00,
1130 0x00, 0x1C, 0x02, 0x00, 0xB4, 0x5F, 0x1D, 0x04,
1131 0x00, 0xCF, 0x5A, 0x13, 0x01, 0x21, 0x05, 0x00,
1132 0x02, 0x03, 0x00, 0x00, 0x00, 0x25, 0x08, 0x00,
1133 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1134 0x26, 0x02, 0x00, 0x22, 0x01, 0x27, 0x05, 0x00,
1135 0xDE, 0x00, 0x32, 0x00, 0x00, 0x28, 0x01, 0x00,
1136 0x00
1137 };
1138
1139 test_port_context_set_command (fixture->ctx,
1140 expected, G_N_ELEMENTS (expected),
1141 response, G_N_ELEMENTS (response),
1142 fixture->service_info[QMI_SERVICE_NAS].transaction_id++);
1143
1144 qmi_client_nas_get_serving_system (QMI_CLIENT_NAS (fixture->service_info[QMI_SERVICE_NAS].client), NULL, 3, NULL,
1145 (GAsyncReadyCallback) nas_get_serving_system_ready,
1146 fixture);
1147
1148 test_fixture_loop_run (fixture);
1149 }
1150
1151 #endif /* HAVE_QMI_MESSAGE_NAS_GET_SERVING_SYSTEM */
1152
1153 /*****************************************************************************/
1154 /* NAS Get System Info */
1155
1156 #if defined HAVE_QMI_MESSAGE_NAS_GET_SYSTEM_INFO
1157
1158 static void
1159 nas_get_system_info_ready (QmiClientNas *client,
1160 GAsyncResult *res,
1161 TestFixture *fixture)
1162 {
1163 QmiMessageNasGetSystemInfoOutput *output;
1164 GError *error = NULL;
1165 gboolean st;
1166
1167 output = qmi_client_nas_get_system_info_finish (client, res, &error);
1168 g_assert_no_error (error);
1169 g_assert (output);
1170
1171 st = qmi_message_nas_get_system_info_output_get_result (output, &error);
1172 g_assert_no_error (error);
1173 g_assert (st);
1174
1175 {
1176 gboolean domain_valid = FALSE;
1177 QmiNasNetworkServiceDomain domain;
1178 gboolean service_capability_valid = FALSE;
1179 QmiNasNetworkServiceDomain service_capability;
1180 gboolean roaming_status_valid = FALSE;
1181 QmiNasRoamingStatus roaming_status;
1182 gboolean forbidden_valid = FALSE;
1183 gboolean forbidden;
1184 gboolean lac_valid = FALSE;
1185 guint16 lac;
1186 gboolean cid_valid = FALSE;
1187 guint32 cid;
1188 gboolean registration_reject_info_valid = FALSE;
1189 QmiNasNetworkServiceDomain registration_reject_domain;
1190 QmiNasRejectCause registration_reject_cause;
1191 gboolean network_id_valid = FALSE;
1192 const gchar *mcc = NULL;
1193 const gchar *mnc = NULL;
1194 gboolean tac_valid = FALSE;
1195 guint16 tac;
1196
1197 /*
1198 * LTE service:
1199 * Status: 'available'
1200 * True Status: 'available'
1201 * Preferred data path: 'no'
1202 * Domain: 'cs-ps'
1203 * Service capability: 'cs-ps'
1204 * Roaming status: 'off'
1205 * Forbidden: 'no'
1206 * Cell ID: '1609474'
1207 * MCC: '530'
1208 * MNC: '24' -- Given as 2 digits, suffixed with 0xFF!
1209 * Tracking Area Code: '63001'
1210 * Voice support: 'yes'
1211 * IMS voice support: 'no'
1212 * eMBMS coverage info support: 'no'
1213 * eMBMS coverage info trace ID: '65535'
1214 * Cell access: 'all-calls'
1215 * Registration restriction: 'unrestricted'
1216 * Registration domain: 'not-applicable'
1217 */
1218
1219 g_assert (qmi_message_nas_get_system_info_output_get_lte_system_info_v2 (
1220 output,
1221 &domain_valid,
1222 &domain,
1223 &service_capability_valid,
1224 &service_capability,
1225 &roaming_status_valid,
1226 &roaming_status,
1227 &forbidden_valid,
1228 &forbidden,
1229 &lac_valid,
1230 &lac,
1231 &cid_valid,
1232 &cid,
1233 &registration_reject_info_valid,
1234 &registration_reject_domain,
1235 &registration_reject_cause,
1236 &network_id_valid,
1237 &mcc,
1238 &mnc,
1239 &tac_valid,
1240 &tac,
1241 &error));
1242 g_assert_no_error (error);
1243 g_assert (domain_valid);
1244 g_assert_cmpuint (domain, ==, QMI_NAS_NETWORK_SERVICE_DOMAIN_CS_PS);
1245 g_assert (service_capability_valid);
1246 g_assert_cmpuint (service_capability, ==, QMI_NAS_NETWORK_SERVICE_DOMAIN_CS_PS);
1247 g_assert (roaming_status_valid);
1248 g_assert_cmpuint (roaming_status, ==, QMI_NAS_ROAMING_STATUS_OFF);
1249 g_assert (forbidden_valid);
1250 g_assert (!forbidden);
1251 g_assert (!lac_valid);
1252 g_assert (cid_valid);
1253 g_assert_cmpuint (cid, ==, 1616133);
1254 g_assert (!registration_reject_info_valid);
1255 g_assert (network_id_valid);
1256 g_assert_cmpstr (mcc, ==, "530");
1257 g_assert_cmpstr (mnc, ==, "24");
1258 g_assert (tac_valid);
1259 g_assert_cmpuint (tac, ==, 63001);
1260 }
1261
1262 qmi_message_nas_get_system_info_output_unref (output);
1263
1264 test_fixture_loop_stop (fixture);
1265 }
1266
1267 static void
1268 test_generated_nas_get_system_info (TestFixture *fixture)
1269 {
1270 guint8 expected[] = {
1271 0x01,
1272 0x0C, 0x00, 0x00, 0x03, 0x01,
1273 0x00, 0x01, 0x00, 0x4D, 0x00, 0x00, 0x00
1274 };
1275 guint8 response[] = {
1276 0x01,
1277 0x9A, 0x00, 0x80, 0x03, 0x01,
1278 0x02, 0x01, 0x00, 0x4D, 0x00, 0x8E, 0x00, 0x02,
1279 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x03,
1280 0x00, 0x00, 0x00, 0x00, 0x13, 0x03, 0x00, 0x00,
1281 0x00, 0x00, 0x14, 0x03, 0x00, 0x02, 0x02, 0x00,
1282 0x19, 0x1D, 0x00, 0x01, 0x03, 0x01, 0x03, 0x01,
1283 0x00, 0x01, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x05,
1284 0xA9, 0x18, 0x00, 0x00, 0x00, 0x00, 0x01, 0x35,
1285 0x33, 0x30, 0x32, 0x34, 0xFF, 0x01, 0x19, 0xF6,
1286 0x1E, 0x02, 0x00, 0xFF, 0xFF, 0x21, 0x01, 0x00,
1287 0x01, 0x26, 0x01, 0x00, 0x00, 0x27, 0x04, 0x00,
1288 0x01, 0x00, 0x00, 0x00, 0x29, 0x01, 0x00, 0x00,
1289 0x2A, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2F,
1290 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x04,
1291 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x02, 0x00,
1292 0xFF, 0xFF, 0x38, 0x04, 0x00, 0x03, 0x00, 0x00,
1293 0x00, 0x39, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
1294 0x3E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44,
1295 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x04,
1296 0x00, 0x04, 0x00, 0x00, 0x00
1297 };
1298
1299 test_port_context_set_command (fixture->ctx,
1300 expected, G_N_ELEMENTS (expected),
1301 response, G_N_ELEMENTS (response),
1302 fixture->service_info[QMI_SERVICE_NAS].transaction_id++);
1303
1304 qmi_client_nas_get_system_info (QMI_CLIENT_NAS (fixture->service_info[QMI_SERVICE_NAS].client), NULL, 3, NULL,
1305 (GAsyncReadyCallback) nas_get_system_info_ready,
1306 fixture);
1307
1308 test_fixture_loop_run (fixture);
1309 }
1310
1311 #endif
1312
1313 /*****************************************************************************/
1314
1315 int main (int argc, char **argv)
1316 {
1317 g_test_init (&argc, &argv, NULL);
1318
1319 /* Test the setup/teardown test methods */
1320 TEST_ADD ("/libqmi-glib/generated/core", test_generated_core);
1321
1322 #if defined HAVE_QMI_MESSAGE_DMS_GET_IDS
1323 TEST_ADD ("/libqmi-glib/generated/dms/get-ids", test_generated_dms_get_ids);
1324 #endif
1325 #if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_PIN_STATUS
1326 TEST_ADD ("/libqmi-glib/generated/dms/uim-get-pin-status", test_generated_dms_uim_get_pin_status);
1327 #endif
1328 #if defined HAVE_QMI_MESSAGE_DMS_UIM_VERIFY_PIN
1329 TEST_ADD ("/libqmi-glib/generated/dms/uim-verify-pin", test_generated_dms_uim_verify_pin);
1330 #endif
1331 #if defined HAVE_QMI_MESSAGE_DMS_GET_TIME
1332 TEST_ADD ("/libqmi-glib/generated/dms/get-time", test_generated_dms_get_time);
1333 #endif
1334
1335 #if defined HAVE_QMI_MESSAGE_NAS_NETWORK_SCAN
1336 TEST_ADD ("/libqmi-glib/generated/nas/network-scan", test_generated_nas_network_scan);
1337 #endif
1338 #if defined HAVE_QMI_MESSAGE_NAS_GET_CELL_LOCATION_INFO
1339 TEST_ADD ("/libqmi-glib/generated/nas/get-cell-location-info/1", test_generated_nas_get_cell_location_info_1);
1340 TEST_ADD ("/libqmi-glib/generated/nas/get-cell-location-info/2", test_generated_nas_get_cell_location_info_2);
1341 TEST_ADD ("/libqmi-glib/generated/nas/get-cell-location-info/invalid", test_generated_nas_get_cell_location_info_invalid);
1342 TEST_ADD ("/libqmi-glib/compat/nas/get-cell-location-info/geran-info", test_compat_nas_get_cell_location_info_geran_info);
1343 #endif
1344 #if defined HAVE_QMI_MESSAGE_NAS_GET_SERVING_SYSTEM
1345 TEST_ADD ("/libqmi-glib/generated/nas/get-serving-system", test_generated_nas_get_serving_system);
1346 #endif
1347 #if defined HAVE_QMI_MESSAGE_NAS_GET_SYSTEM_INFO
1348 TEST_ADD ("/libqmi-glib/generated/nas/get-system-info", test_generated_nas_get_system_info);
1349 #endif
1350
1351 return g_test_run ();
1352 }