billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=3cc3f3ee2a25a69c74e39f8af7f6a9cf351e478e

commit 3cc3f3ee2a25a69c74e39f8af7f6a9cf351e478e
Author: Boris Faure <[email protected]>
Date:   Sat Dec 15 17:00:46 2018 +0100

    add tytest.h and colors_256_get() to be able to test truecolor
---
 src/bin/col.c        | 13 +++++++++++++
 src/bin/col.h        |  1 +
 src/bin/meson.build  |  2 +-
 src/bin/termptyesc.c |  6 +++++-
 src/bin/tyfuzz.c     | 37 +++++++++++++++++++++++++++++++++++++
 src/bin/tytest.h     | 15 +++++++++++++++
 6 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/src/bin/col.c b/src/bin/col.c
index 57b2a56..8b1da89 100644
--- a/src/bin/col.c
+++ b/src/bin/col.c
@@ -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;
+}
diff --git a/src/bin/col.h b/src/bin/col.h
index 2fe8dfe..d2cf605 100644
--- a/src/bin/col.h
+++ b/src/bin/col.h
@@ -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
diff --git a/src/bin/meson.build b/src/bin/meson.build
index eb75b69..44ea008 100644
--- a/src/bin/meson.build
+++ b/src/bin/meson.build
@@ -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,
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 857b654..d1a0d9a 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -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;
diff --git a/src/bin/tyfuzz.c b/src/bin/tyfuzz.c
index 70da12c..175173b 100644
--- a/src/bin/tyfuzz.c
+++ b/src/bin/tyfuzz.c
@@ -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)
diff --git a/src/bin/tytest.h b/src/bin/tytest.h
new file mode 100644
index 0000000..e702cec
--- /dev/null
+++ b/src/bin/tytest.h
@@ -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

-- 


Reply via email to