diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-05-24 12:35:44 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-06-05 19:15:15 +0200 |
commit | 700ebc5c07ce667204f95dbe61716234131c15fb (patch) | |
tree | b31f281dbcd072cbb360847f858e0eda5af67a8f /src/tests/test-modem-helpers.c | |
parent | 1c67d050cb0451a63c8fdb0bd673892bdc04e4e0 (diff) |
api,introspection: rename 'ModemCapabilities' to 'SupportedCapabilities'
And also make it a list of masks, specifying which are the specific combinations
supported, not just one mask with all.
E.g.:
-------------------------
Hardware | manufacturer: 'Sierra Wireless, Incorporated'
| model: 'MC7710'
| revision: 'SWI9200X_03.05.19.04ap r5475 carmd-en-10527 2012/09/17 17:57:14'
| supported: 'gsm-umts
| gsm-umts, lte'
| current: 'gsm-umts, lte'
| equipment id: '358178040668164'
Diffstat (limited to 'src/tests/test-modem-helpers.c')
-rw-r--r-- | src/tests/test-modem-helpers.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c index c61f190c..f988dfaa 100644 --- a/src/tests/test-modem-helpers.c +++ b/src/tests/test-modem-helpers.c @@ -2053,6 +2053,98 @@ test_supported_mode_filter (void *f, gpointer d) /*****************************************************************************/ +static gboolean +find_capability_combination (GArray *capabilities, + MMModemCapability capability) +{ + guint i; + + for (i = 0; i < capabilities->len; i++) { + MMModemCapability capability_i; + + capability_i = g_array_index (capabilities, MMModemCapability, i); + if (capability_i == capability) + return TRUE; + } + + return FALSE; +} + +static void +test_supported_capability_filter (void *f, gpointer d) +{ + MMModemCapability capability; + GArray *combinations; + GArray *filtered; + + combinations = g_array_sized_new (FALSE, FALSE, sizeof (MMModemCapability), 6); + + /* GSM/UMTS only */ + capability = MM_MODEM_CAPABILITY_GSM_UMTS; + g_array_append_val (combinations, capability); + /* CDMA/EVDO only */ + capability = MM_MODEM_CAPABILITY_CDMA_EVDO; + g_array_append_val (combinations, capability); + /* GSM/UMTS and CDMA/EVDO */ + capability = (MM_MODEM_CAPABILITY_CDMA_EVDO | MM_MODEM_CAPABILITY_GSM_UMTS); + g_array_append_val (combinations, capability); + /* GSM/UMTS+LTE */ + capability = (MM_MODEM_CAPABILITY_GSM_UMTS | MM_MODEM_CAPABILITY_LTE); + g_array_append_val (combinations, capability); + /* CDMA/EVDO+LTE */ + capability = (MM_MODEM_CAPABILITY_CDMA_EVDO | MM_MODEM_CAPABILITY_LTE); + g_array_append_val (combinations, capability); + /* GSM/UMTS+CDMA/EVDO+LTE */ + capability = (MM_MODEM_CAPABILITY_GSM_UMTS | MM_MODEM_CAPABILITY_CDMA_EVDO | MM_MODEM_CAPABILITY_LTE); + g_array_append_val (combinations, capability); + + /* Only GSM-UMTS supported */ + filtered = mm_filter_supported_capabilities (MM_MODEM_CAPABILITY_GSM_UMTS, combinations); + g_assert_cmpuint (filtered->len, ==, 1); + g_assert (find_capability_combination (filtered, MM_MODEM_CAPABILITY_GSM_UMTS)); + g_array_unref (filtered); + + /* Only CDMA-EVDO supported */ + filtered = mm_filter_supported_capabilities (MM_MODEM_CAPABILITY_CDMA_EVDO, combinations); + g_assert_cmpuint (filtered->len, ==, 1); + g_assert (find_capability_combination (filtered, MM_MODEM_CAPABILITY_CDMA_EVDO)); + g_array_unref (filtered); + + /* GSM-UMTS and CDMA-EVDO supported */ + filtered = mm_filter_supported_capabilities ((MM_MODEM_CAPABILITY_CDMA_EVDO | + MM_MODEM_CAPABILITY_GSM_UMTS), + combinations); + g_assert_cmpuint (filtered->len, ==, 3); + g_assert (find_capability_combination (filtered, MM_MODEM_CAPABILITY_CDMA_EVDO)); + g_assert (find_capability_combination (filtered, MM_MODEM_CAPABILITY_GSM_UMTS)); + g_assert (find_capability_combination (filtered, (MM_MODEM_CAPABILITY_GSM_UMTS | + MM_MODEM_CAPABILITY_CDMA_EVDO))); + g_array_unref (filtered); + + /* GSM-UMTS, CDMA-EVDO and LTE supported */ + filtered = mm_filter_supported_capabilities ((MM_MODEM_CAPABILITY_CDMA_EVDO | + MM_MODEM_CAPABILITY_GSM_UMTS | + MM_MODEM_CAPABILITY_LTE), + combinations); + g_assert_cmpuint (filtered->len, ==, 6); + g_assert (find_capability_combination (filtered, MM_MODEM_CAPABILITY_CDMA_EVDO)); + g_assert (find_capability_combination (filtered, MM_MODEM_CAPABILITY_GSM_UMTS)); + g_assert (find_capability_combination (filtered, (MM_MODEM_CAPABILITY_GSM_UMTS | + MM_MODEM_CAPABILITY_CDMA_EVDO))); + g_assert (find_capability_combination (filtered, (MM_MODEM_CAPABILITY_GSM_UMTS | + MM_MODEM_CAPABILITY_LTE))); + g_assert (find_capability_combination (filtered, (MM_MODEM_CAPABILITY_CDMA_EVDO | + MM_MODEM_CAPABILITY_LTE))); + g_assert (find_capability_combination (filtered, (MM_MODEM_CAPABILITY_GSM_UMTS | + MM_MODEM_CAPABILITY_CDMA_EVDO | + MM_MODEM_CAPABILITY_LTE))); + g_array_unref (filtered); + + g_array_unref (combinations); +} + +/*****************************************************************************/ + void _mm_log (const char *loc, const char *func, @@ -2184,6 +2276,8 @@ int main (int argc, char **argv) g_test_suite_add (suite, TESTCASE (test_supported_mode_filter, NULL)); + g_test_suite_add (suite, TESTCASE (test_supported_capability_filter, NULL)); + result = g_test_run (); reg_test_data_free (reg_data); |