4 #include "test_common.h"
9 void (*gpTest_VT100_AddText)(size_t Length, const char *UTF8Text);
10 void (*gpTest_VT100_SetTitle)(const char *Title);
13 int Test_VT100_Setup(void)
15 gpTest_VT100_AddText = NULL;
16 gpTest_VT100_SetTitle = NULL;
20 int Test_VT100_int_Command(int MaxCalls, const char *Command)
22 const char *buf = Command;
23 int len = strlen(Command);
27 TEST_ASSERT_R(nCalls, <, MaxCalls);
28 int rv = Term_HandleVT100(NULL, len, buf);
31 TEST_ASSERT_R(rv, !=, 0);
32 TEST_ASSERT_R(rv, <=, len);
41 void Test_VT100_TitleSet(void)
43 #define TITLE1 "Testing Title, quite long and complex ;;"
44 const char cmd_long_long[] = "\033]0;"TITLE1"\033\\";
45 #define TITLE2 "Another completely[]different title--"
46 const char cmd_long_st[] = "\033]0;"TITLE2"\x9c";
47 #define TITLE3 "12345678b sbuog egu nz vlj=+~`][]\033 "
48 const char cmd_long_bel[] = "\033]0;"TITLE3"\007";
49 const char *expected_title;
51 int title_was_set=0, rv;
53 void _settitle(const char *Title) {
54 TEST_ASSERT_SR( Title, ==, expected_title );
57 gpTest_VT100_SetTitle = _settitle;
59 expected_title = TITLE1;
61 rv = Test_VT100_int_Command(10, cmd_long_long);
62 TEST_ASSERT_R(rv, ==, sizeof(cmd_long_long)-1);
63 TEST_ASSERT(title_was_set);
65 expected_title = TITLE2;
67 rv = Test_VT100_int_Command(10, cmd_long_st);
68 TEST_ASSERT_R(rv, ==, sizeof(cmd_long_st)-1);
69 TEST_ASSERT(title_was_set);
71 expected_title = TITLE3;
73 rv = Test_VT100_int_Command(10, cmd_long_bel);
74 TEST_ASSERT_R(rv, ==, sizeof(cmd_long_bel)-1);
75 TEST_ASSERT(title_was_set);
80 {"VT100 TitleSet", NULL, Test_VT100_TitleSet, NULL}
82 int giNumTests = sizeof(gaTests)/sizeof(gaTests[0]);
86 void *Display_GetTermState(tTerminal *Term) {
87 return gpTermStatePtr;
89 void Display_SetTermState(tTerminal *Term, void *State) {
90 gpTermStatePtr = State;
93 void Display_AddText(tTerminal *Term, size_t Length, const char *UTF8Text) {
94 TEST_ASSERT(gpTest_VT100_AddText);
95 gpTest_VT100_AddText(Length, UTF8Text);
97 void Display_Newline(tTerminal *Term, bool bCarriageReturn) {
98 //if( gpTest_VT100_Newline )
99 // gpTest_VT100_Newline(Term, bCarriageReturn);
101 void Display_SetScrollArea(tTerminal *Term, int Start, int Count) {
102 //if( gpTest_VT100_SetScrollArea )
103 // gpTest_VT100_SetScrollArea(Term, Start, Count);
105 void Display_ScrollDown(tTerminal *Term, int Count) {
107 void Display_SetCursor(tTerminal *Term, int Row, int Col) {
109 void Display_MoveCursor(tTerminal *Term, int RelRow, int RelCol) {
111 void Display_SaveCursor(tTerminal *Term) {
113 void Display_RestoreCursor(tTerminal *Term) {
115 void Display_ClearLine(tTerminal *Term, int Dir) { // 0: All, 1: Forward, -1: Reverse
117 void Display_ClearLines(tTerminal *Term, int Dir) { // 0: All, 1: Forward, -1: Reverse
119 void Display_ResetAttributes(tTerminal *Term) {
121 void Display_SetForeground(tTerminal *Term, uint32_t RGB) {
123 void Display_SetBackground(tTerminal *Term, uint32_t RGB) {
125 void Display_Flush(tTerminal *Term) {
127 void Display_ShowAltBuffer(tTerminal *Term, bool AltBufEnabled) {
129 void Display_SetTitle(tTerminal *Term, const char *Title) {
130 TEST_ASSERT(gpTest_VT100_SetTitle);
131 gpTest_VT100_SetTitle(Title);