add tytest.h and colors_256_get() to be able to test truecolor

terminology-1.4
Boris Faure 4 years ago
parent 119a4d12af
commit 3cc3f3ee2a
  1. 13
      src/bin/col.c
  2. 1
      src/bin/col.h
  3. 2
      src/bin/meson.build
  4. 6
      src/bin/termptyesc.c
  5. 37
      src/bin/tyfuzz.c
  6. 15
      src/bin/tytest.h

@ -515,3 +515,16 @@ colors_standard_get(int set, int col,
*b = 0;
*a = 0;
}
void
colors_256_get(int col,
unsigned char *r,
unsigned char *g,
unsigned char *b,
unsigned char *a)
{
*r = default_colors256[col].r;
*g = default_colors256[col].g;
*b = default_colors256[col].b;
*a = default_colors256[col].a;
}

@ -6,5 +6,6 @@
void colors_term_init(Evas_Object *textgrid, const Evas_Object *bg, const Config *config);
void colors_standard_get(int set, int col, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a);
void colors_256_get(int col, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a);
#endif

@ -69,7 +69,7 @@ tytest_sources = ['termptyesc.c', 'termptyesc.h',
'col.c', 'col.h',
'sb.c', 'sb.h',
'md5/md5.c', 'md5/md5.h',
'tytest.c']
'tytest.c', 'tytest.h']
executable('terminology',
terminology_sources,

@ -1,12 +1,16 @@
#include "private.h"
#include <Elementary.h>
#include <stdint.h>
#include "col.h"
#include "termio.h"
#include "termpty.h"
#include "termptydbl.h"
#include "termptyesc.h"
#include "termptyops.h"
#include "termptyext.h"
#if defined(ENABLE_TESTS)
#include "tytest.h"
#endif
#undef CRITICAL
#undef ERR
@ -579,7 +583,7 @@ _approximate_truecolor_rgb(Termpty *ty, int r0, int g0, int b0)
{
int chosen_color = COL_DEF;
/* TODO: use the function in tests */
#if defined(ENABLE_FUZZING) || defined(ENABLE_TESTS)
#if defined(ENABLE_FUZZING)
(void) ty;
(void) r0;
(void) g0;

@ -14,6 +14,8 @@
#include <assert.h>
#ifdef TYTEST
#include "col.h"
#include "tytest.h"
#include "md5/md5.h"
#endif
@ -90,6 +92,41 @@ typedef struct _Termpty_Tests
unsigned int bracketed_paste : 1;
} Termpty_Tests;
Evas_Object *
termio_textgrid_get(const Evas_Object *obj EINA_UNUSED)
{
return NULL;
}
void
test_textgrid_palette_get(const Evas_Object *obj EINA_UNUSED,
Evas_Textgrid_Palette pal,
int idx,
int *r,
int *g,
int *b,
int *a)
{
if (pal == EVAS_TEXTGRID_PALETTE_EXTENDED)
{
colors_256_get(idx,
(unsigned char *)r,
(unsigned char *)g,
(unsigned char *)b,
(unsigned char *)a);
}
else
{
int set = idx / 12;
int col = idx % 12;
colors_standard_get(set, col,
(unsigned char*)r,
(unsigned char*)g,
(unsigned char*)b,
(unsigned char*)a);
}
}
void
termio_set_cursor_shape(Evas_Object *obj EINA_UNUSED,
Cursor_Shape shape EINA_UNUSED)

@ -0,0 +1,15 @@
#ifndef _TYTEST_H__
#define _TYTEST_H__ 1
#if defined(ENABLE_TESTS)
#define evas_object_textgrid_palette_get test_textgrid_palette_get
void
test_textgrid_palette_get(const Evas_Object *obj,
Evas_Textgrid_Palette pal,
int idx,
int *r,
int *g,
int *b,
int *a);
#endif
#endif
Loading…
Cancel
Save