mirror of git://git.sysmocom.de/ofono
Update unit test for USAT display text command
This commit is contained in:
parent
d90aa1561f
commit
c26619539d
|
@ -317,7 +317,8 @@ unit_test_simutil_LDADD = @GLIB_LIBS@
|
|||
unit_objects += $(unit_test_simutil_OBJECTS)
|
||||
|
||||
unit_test_stkutil_SOURCES = unit/test-stkutil.c src/util.c \
|
||||
src/stkutil.c
|
||||
src/storage.c src/smsutil.c \
|
||||
src/simutil.c src/stkutil.c
|
||||
unit_test_stkutil_LDADD = @GLIB_LIBS@
|
||||
unit_objects += $(unit_test_stkutil_OBJECTS)
|
||||
|
||||
|
|
|
@ -31,15 +31,206 @@
|
|||
#include <glib.h>
|
||||
#include <glib/gprintf.h>
|
||||
|
||||
static void test_display_text_111()
|
||||
#include <ofono/types.h>
|
||||
#include "stkutil.h"
|
||||
|
||||
struct display_text_test {
|
||||
const unsigned char *pdu;
|
||||
unsigned int pdu_len;
|
||||
const char *expected;
|
||||
unsigned char qualifier;
|
||||
};
|
||||
|
||||
unsigned char display_text_111[] = { 0xD0, 0x1A, 0x81, 0x03, 0x01, 0x21, 0x80,
|
||||
0x82, 0x02, 0x81, 0x02, 0x8D, 0x0F,
|
||||
0x04, 0x54, 0x6F, 0x6F, 0x6C, 0x6B,
|
||||
0x69, 0x74, 0x20, 0x54, 0x65, 0x73,
|
||||
0x74, 0x20, 0x31 };
|
||||
|
||||
unsigned char display_text_131[] = { 0xD0, 0x1A, 0x81, 0x03, 0x01, 0x21, 0x81,
|
||||
0x82, 0x02, 0x81, 0x02, 0x8D, 0x0F,
|
||||
0x04, 0x54, 0x6F, 0x6F, 0x6C, 0x6B,
|
||||
0x69, 0x74, 0x20, 0x54, 0x65, 0x73,
|
||||
0x74, 0x20, 0x32 };
|
||||
|
||||
unsigned char display_text_141[] = { 0xD0, 0x19, 0x81, 0x03, 0x01, 0x21, 0x80,
|
||||
0x82, 0x02, 0x81, 0x02, 0x8D, 0x0E,
|
||||
0x00, 0xD4, 0xF7, 0x9B, 0xBD, 0x4E,
|
||||
0xD3, 0x41, 0xD4, 0xF2, 0x9C, 0x0E,
|
||||
0x9A, 0x01 };
|
||||
|
||||
unsigned char display_text_151[] = { 0xD0, 0x1A, 0x81, 0x03, 0x01, 0x21, 0x00,
|
||||
0x82, 0x02, 0x81, 0x02, 0x8D, 0x0F,
|
||||
0x04, 0x54, 0x6F, 0x6F, 0x6C, 0x6B,
|
||||
0x69, 0x74, 0x20, 0x54, 0x65, 0x73,
|
||||
0x74, 0x20, 0x34 };
|
||||
|
||||
unsigned char display_text_161[] = { 0xD0, 0x81, 0xAD, 0x81, 0x03, 0x01, 0x21,
|
||||
0x80, 0x82, 0x02, 0x81, 0x02, 0x8D,
|
||||
0x81, 0xA1, 0x04, 0x54, 0x68, 0x69,
|
||||
0x73, 0x20, 0x63, 0x6F, 0x6D, 0x6D,
|
||||
0x61, 0x6E, 0x64, 0x20, 0x69, 0x6E,
|
||||
0x73, 0x74, 0x72, 0x75, 0x63, 0x74,
|
||||
0x73, 0x20, 0x74, 0x68, 0x65, 0x20,
|
||||
0x4D, 0x45, 0x20, 0x74, 0x6F, 0x20,
|
||||
0x64, 0x69, 0x73, 0x70, 0x6C, 0x61,
|
||||
0x79, 0x20, 0x61, 0x20, 0x74, 0x65,
|
||||
0x78, 0x74, 0x20, 0x6D, 0x65, 0x73,
|
||||
0x73, 0x61, 0x67, 0x65, 0x2E, 0x20,
|
||||
0x49, 0x74, 0x20, 0x61, 0x6C, 0x6C,
|
||||
0x6F, 0x77, 0x73, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x53, 0x49, 0x4D, 0x20,
|
||||
0x74, 0x6F, 0x20, 0x64, 0x65, 0x66,
|
||||
0x69, 0x6E, 0x65, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x70, 0x72, 0x69, 0x6F,
|
||||
0x72, 0x69, 0x74, 0x79, 0x20, 0x6F,
|
||||
0x66, 0x20, 0x74, 0x68, 0x61, 0x74,
|
||||
0x20, 0x6D, 0x65, 0x73, 0x73, 0x61,
|
||||
0x67, 0x65, 0x2C, 0x20, 0x61, 0x6E,
|
||||
0x64, 0x20, 0x74, 0x68, 0x65, 0x20,
|
||||
0x74, 0x65, 0x78, 0x74, 0x20, 0x73,
|
||||
0x74, 0x72, 0x69, 0x6E, 0x67, 0x20,
|
||||
0x66, 0x6F, 0x72, 0x6D, 0x61, 0x74,
|
||||
0x2E, 0x20, 0x54, 0x77, 0x6F, 0x20,
|
||||
0x74, 0x79, 0x70, 0x65, 0x73, 0x20,
|
||||
0x6F, 0x66, 0x20, 0x70, 0x72, 0x69,
|
||||
0x6F };
|
||||
|
||||
unsigned char display_text_171[] = { 0xD0, 0x1A, 0x81, 0x03, 0x01, 0x21, 0x80,
|
||||
0x82, 0x02, 0x81, 0x02, 0x8D, 0x0F,
|
||||
0x04, 0x3C, 0x47, 0x4F, 0x2D, 0x42,
|
||||
0x41, 0x43, 0x4B, 0x57, 0x41, 0x52,
|
||||
0x44, 0x53, 0x3E };
|
||||
|
||||
unsigned char display_text_611[] = { 0xD0, 0x24, 0x81, 0x03, 0x01, 0x21, 0x80,
|
||||
0x82, 0x02, 0x81, 0x02, 0x8D, 0x19,
|
||||
0x08, 0x04, 0x17, 0x04, 0x14, 0x04,
|
||||
0x20, 0x04, 0x10, 0x04, 0x12, 0x04,
|
||||
0x21, 0x04, 0x22, 0x04, 0x12, 0x04,
|
||||
0x23, 0x04, 0x19, 0x04, 0x22, 0x04,
|
||||
0x15 };
|
||||
|
||||
unsigned char display_text_911[] = { 0xD0, 0x10, 0x81, 0x03, 0x01, 0x21, 0x80,
|
||||
0x82, 0x02, 0x81, 0x02, 0x8D, 0x05,
|
||||
0x08, 0x4F, 0x60, 0x59, 0x7D };
|
||||
|
||||
unsigned char display_text_1011[] = { 0xD0, 0x12, 0x81, 0x03, 0x01, 0x21, 0x80,
|
||||
0x82, 0x02, 0x81, 0x02, 0x8D, 0x07,
|
||||
0x08, 0x00, 0x38, 0x00, 0x30, 0x30,
|
||||
0xEB };
|
||||
|
||||
static struct display_text_test display_text_data_111 = {
|
||||
.pdu = display_text_111,
|
||||
.pdu_len = sizeof(display_text_111),
|
||||
.expected = "Toolkit Test 1",
|
||||
.qualifier = 0x80
|
||||
};
|
||||
|
||||
static struct display_text_test display_text_data_131 = {
|
||||
.pdu = display_text_131,
|
||||
.pdu_len = sizeof(display_text_131),
|
||||
.expected = "Toolkit Test 2",
|
||||
.qualifier = 0x81
|
||||
};
|
||||
|
||||
static struct display_text_test display_text_data_141 = {
|
||||
.pdu = display_text_141,
|
||||
.pdu_len = sizeof(display_text_141),
|
||||
.expected = "Toolkit Test 3",
|
||||
.qualifier = 0x80
|
||||
};
|
||||
|
||||
static struct display_text_test display_text_data_151 = {
|
||||
.pdu = display_text_151,
|
||||
.pdu_len = sizeof(display_text_151),
|
||||
.expected = "Toolkit Test 4",
|
||||
.qualifier = 0x00
|
||||
};
|
||||
|
||||
static struct display_text_test display_text_data_161 = {
|
||||
.pdu = display_text_161,
|
||||
.pdu_len = sizeof(display_text_161),
|
||||
.expected = "This command instructs the ME to display a text message. "
|
||||
"It allows the SIM to define the priority of that "
|
||||
"message, and the text string format. Two types of "
|
||||
"prio",
|
||||
.qualifier = 0x80
|
||||
};
|
||||
|
||||
static struct display_text_test display_text_data_171 = {
|
||||
.pdu = display_text_171,
|
||||
.pdu_len = sizeof(display_text_171),
|
||||
.expected = "<GO-BACKWARDS>",
|
||||
.qualifier = 0x80
|
||||
};
|
||||
|
||||
static struct display_text_test display_text_data_611 = {
|
||||
.pdu = display_text_611,
|
||||
.pdu_len = sizeof(display_text_611),
|
||||
.expected = "ЗДРАВСТВУЙТЕ",
|
||||
.qualifier = 0x80
|
||||
};
|
||||
|
||||
static struct display_text_test display_text_data_911 = {
|
||||
.pdu = display_text_911,
|
||||
.pdu_len = sizeof(display_text_911),
|
||||
.expected = "你好",
|
||||
.qualifier = 0x80
|
||||
};
|
||||
|
||||
static struct display_text_test display_text_data_1011 = {
|
||||
.pdu = display_text_1011,
|
||||
.pdu_len = sizeof(display_text_1011),
|
||||
.expected = "80ル",
|
||||
.qualifier = 0x80
|
||||
};
|
||||
|
||||
/* Defined in TS 102.384 Section 27.22.4.1.1.4.2 */
|
||||
static void test_display_text(gconstpointer data)
|
||||
{
|
||||
const struct display_text_test *test = data;
|
||||
struct stk_command *command;
|
||||
|
||||
command = stk_command_new_from_pdu(test->pdu, test->pdu_len);
|
||||
|
||||
g_assert(command);
|
||||
|
||||
g_assert(command->number == 1);
|
||||
g_assert(command->type == STK_COMMAND_TYPE_DISPLAY_TEXT);
|
||||
g_assert(command->qualifier == test->qualifier);
|
||||
|
||||
g_assert(command->src == STK_DEVICE_IDENTITY_TYPE_UICC);
|
||||
g_assert(command->dst == STK_DEVICE_IDENTITY_TYPE_DISPLAY);
|
||||
|
||||
g_assert(command->display_text.text);
|
||||
|
||||
g_assert(g_str_equal(test->expected, command->display_text.text));
|
||||
|
||||
stk_command_free(command);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func("/teststk/Display Text 111", test_display_text_111);
|
||||
g_test_add_data_func("/teststk/Display Text 1.1.1",
|
||||
&display_text_data_111, test_display_text);
|
||||
g_test_add_data_func("/teststk/Display Text 1.3.1",
|
||||
&display_text_data_131, test_display_text);
|
||||
g_test_add_data_func("/teststk/Display Text 1.4.1",
|
||||
&display_text_data_141, test_display_text);
|
||||
g_test_add_data_func("/teststk/Display Text 1.5.1",
|
||||
&display_text_data_151, test_display_text);
|
||||
g_test_add_data_func("/teststk/Display Text 1.6.1",
|
||||
&display_text_data_161, test_display_text);
|
||||
g_test_add_data_func("/teststk/Display Text 1.7.1",
|
||||
&display_text_data_171, test_display_text);
|
||||
g_test_add_data_func("/teststk/Display Text 6.1.1",
|
||||
&display_text_data_611, test_display_text);
|
||||
g_test_add_data_func("/teststk/Display Text 9.1.1",
|
||||
&display_text_data_911, test_display_text);
|
||||
g_test_add_data_func("/teststk/Display Text 10.1.1",
|
||||
&display_text_data_1011, test_display_text);
|
||||
|
||||
return g_test_run();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue