diff options
author | Lukas Voegl <lvoegl@tdt.de> | 2024-10-31 15:31:05 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2024-11-20 12:07:20 +0000 |
commit | 32435b430f9803f348db37e455b4db5298db1d8f (patch) | |
tree | c9ce4fb5fb81469b9d9890386e0c4a8563d91d6c /src/plugins/cinterion/tests/test-modem-helpers-cinterion.c | |
parent | 3de6cca46d83d08126cdf0d355a52639d255954b (diff) |
broadband-modem-cinterion: never discard operator or mode
When setting an operator, AT+COPS overwrites the currently set allowed mode. Equally, the other way around, when setting the current mode, the configured operator is overwritten.
Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
Diffstat (limited to 'src/plugins/cinterion/tests/test-modem-helpers-cinterion.c')
-rw-r--r-- | src/plugins/cinterion/tests/test-modem-helpers-cinterion.c | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/src/plugins/cinterion/tests/test-modem-helpers-cinterion.c b/src/plugins/cinterion/tests/test-modem-helpers-cinterion.c index d4816199..ae76223c 100644 --- a/src/plugins/cinterion/tests/test-modem-helpers-cinterion.c +++ b/src/plugins/cinterion/tests/test-modem-helpers-cinterion.c @@ -1855,6 +1855,132 @@ test_sxrat_response_other (void) g_array_unref (expected_pref1); } +static void +test_cops_only_mode_2g (void) +{ + const gchar *operator = NULL; + MMModemMode mode = MM_MODEM_MODE_2G; + GError *error = NULL; + g_autofree gchar *cops_command = NULL; + gboolean res; + + res = mm_cinterion_build_cops_set_command (mode, + operator, + &cops_command, + &error); + g_assert_no_error (error); + g_assert (res == TRUE); + g_assert_cmpstr (cops_command, ==, "+COPS=0,,,0"); +} + +static void +test_cops_only_mode_3g (void) +{ + const gchar *operator = NULL; + MMModemMode mode = MM_MODEM_MODE_3G; + GError *error = NULL; + g_autofree gchar *cops_command = NULL; + gboolean res; + + res = mm_cinterion_build_cops_set_command (mode, + operator, + &cops_command, + &error); + g_assert_no_error (error); + g_assert (res == TRUE); + g_assert_cmpstr (cops_command, ==, "+COPS=0,,,2"); +} + +static void +test_cops_only_mode_4g (void) +{ + const gchar *operator = NULL; + MMModemMode mode = MM_MODEM_MODE_4G; + GError *error = NULL; + g_autofree gchar *cops_command = NULL; + gboolean res; + + res = mm_cinterion_build_cops_set_command (mode, + operator, + &cops_command, + &error); + g_assert_no_error (error); + g_assert (res == TRUE); + g_assert_cmpstr (cops_command, ==, "+COPS=0,,,7"); +} + +static void +test_cops_only_mode_other (void) +{ + const gchar *operator = NULL; + MMModemMode mode = MM_MODEM_MODE_5G; + GError *error = NULL; + gchar *cops_command = NULL; + gboolean res; + + res = mm_cinterion_build_cops_set_command (mode, + operator, + &cops_command, + &error); + g_assert (res == FALSE); + g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED); + g_clear_error (&error); +} + +static void +test_cops_only_operator (void) +{ + const gchar *operator = "26201"; + MMModemMode mode = MM_MODEM_MODE_ANY; + GError *error = NULL; + g_autofree gchar *cops_command = NULL; + gboolean res; + + res = mm_cinterion_build_cops_set_command (mode, + operator, + &cops_command, + &error); + g_assert_no_error (error); + g_assert (res == TRUE); + g_assert_cmpstr (cops_command, ==, "+COPS=1,2,\"26201\""); +} + +static void +test_cops_operator_and_mode (void) +{ + const gchar *operator = "26202"; + MMModemMode mode = MM_MODEM_MODE_2G; + GError *error = NULL; + g_autofree gchar *cops_command = NULL; + gboolean res; + + res = mm_cinterion_build_cops_set_command (mode, + operator, + &cops_command, + &error); + g_assert_no_error (error); + g_assert (res == TRUE); + g_assert_cmpstr (cops_command, ==, "+COPS=1,2,\"26202\",0"); +} + +static void +test_cops_any (void) +{ + const gchar *operator = NULL; + MMModemMode mode = MM_MODEM_MODE_ANY; + GError *error = NULL; + g_autofree gchar *cops_command = NULL; + gboolean res; + + res = mm_cinterion_build_cops_set_command (mode, + operator, + &cops_command, + &error); + g_assert_no_error (error); + g_assert (res == TRUE); + g_assert_cmpstr (cops_command, ==, "+COPS=0"); +} + typedef struct { const gchar *str; MMModemMode allowed; @@ -1962,6 +2088,13 @@ int main (int argc, char **argv) g_test_add_func ("/MM/cinterion/sxrat", test_sxrat); g_test_add_func ("/MM/cinterion/sxrat/response/els61", test_sxrat_response_els61); g_test_add_func ("/MM/cinterion/sxrat/response/other", test_sxrat_response_other); + g_test_add_func ("/MM/cinterion/cops/only-mode-2g", test_cops_only_mode_2g); + g_test_add_func ("/MM/cinterion/cops/only-mode-3g", test_cops_only_mode_3g); + g_test_add_func ("/MM/cinterion/cops/only-mode-4g", test_cops_only_mode_4g); + g_test_add_func ("/MM/cinterion/cops/only-mode-other", test_cops_only_mode_other); + g_test_add_func ("/MM/cinterion/cops/only-operator", test_cops_only_operator); + g_test_add_func ("/MM/cinterion/cops/operator-and-mode", test_cops_operator_and_mode); + g_test_add_func ("/MM/cinterion/cops/any", test_cops_any); return g_test_run (); } |