elementary: merging in elm_code widget.

Theme is not there as it should be manually merged into the elementary
default theme.
This commit is contained in:
Cedric BAIL 2016-06-02 17:19:08 -07:00
parent 9f129a8711
commit d384012307
43 changed files with 225 additions and 271 deletions

View File

@ -1,130 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Ecore_Getopt.h>
#include "Elm_Code.h"
#include "elm_code_suite.h"
#define COPYRIGHT "Copyright © 2014 Andy Williams <andy@andyilliams.me> and various contributors (see AUTHORS)."
static const struct {
const char *name;
void (*build)(TCase *tc);
} tests[] = {
{ "file_load", elm_code_file_test_load },
{ "file_memory", elm_code_file_test_memory },
{ "parse", elm_code_test_parse },
{ "text", elm_code_test_text },
{ "basic", elm_code_test_basic },
{ "widget", elm_code_test_widget },
{ "widget_text", elm_code_test_widget_text },
{ "widget_selection", elm_code_test_widget_selection },
{ "widget_undo", elm_code_test_widget_undo },
};
START_TEST(elm_code_initialization)
{
fail_if(elm_code_init() != 1);
// TODO add other init checks here
fail_if(elm_code_shutdown() != 0);
}
END_TEST
void
edi_test_basic(TCase *tc)
{
tcase_add_test(tc, elm_code_initialization);
}
static const Ecore_Getopt optdesc = {
"elm_code",
"%prog [options]",
PACKAGE_VERSION,
COPYRIGHT,
"BSD with advertisement clause",
"Elm Code",
0,
{
ECORE_GETOPT_STORE_TRUE('l', "list", "list available tests"),
ECORE_GETOPT_STORE_STR('t', "test", "test to run"),
ECORE_GETOPT_LICENSE('L', "license"),
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
ECORE_GETOPT_VERSION('V', "version"),
ECORE_GETOPT_HELP('h', "help"),
ECORE_GETOPT_SENTINEL
}
};
int
main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Suite *s;
SRunner *sr;
TCase *tc = NULL;
char *test = NULL;
unsigned int i;
int failed_count = -1;
int args;
Eina_Bool quit_option = EINA_FALSE;
Eina_Bool list_option = EINA_FALSE;
Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_BOOL(list_option),
ECORE_GETOPT_VALUE_STR(test),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_NONE
};
eina_init();
args = ecore_getopt_parse(&optdesc, values, argc, argv);
if (args < 0)
{
EINA_LOG_CRIT("Could not parse arguments.");
goto end;
}
else if (quit_option)
{
goto end;
}
else if (list_option)
{
fprintf(stdout, "Available tests :\n");
for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
fprintf(stdout, "\t%s\n", tests[i].name);
goto end;
}
s = suite_create("Elm_Code");
for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
{
if (test && strcmp(tests[i].name, test))
continue ;
tc = tcase_create(tests[i].name);
tcase_set_timeout(tc, 0);
tests[i].build(tc);
suite_add_tcase(s, tc);
}
sr = srunner_create(s);
srunner_set_xml(sr, PACKAGE_BUILD_DIR "/check-results.xml");
srunner_run_all(sr, CK_ENV);
failed_count = srunner_ntests_failed(sr);
srunner_free(sr);
end:
eina_shutdown();
return (failed_count == 0) ? 0 : 255;
}

View File

@ -1,31 +0,0 @@
#ifndef _ELM_CODE_SUITE_H
#define _ELM_CODE_SUITE_H
#include <check.h>
#define ck_assert_strn_eq(s1, s2, len) \
{ \
char expected[len+1], actual[len+1]; \
\
strncpy(expected, s1, len); \
expected[len] = '\0'; \
strncpy(actual, s2, len); \
actual[len] = '\0'; \
\
ck_assert_str_eq(expected, actual); \
}
#include <Elm_Code.h>
void elm_code_file_test_load(TCase *tc);
void elm_code_file_test_memory(TCase *tc);
void elm_code_test_basic(TCase *tc);
void elm_code_test_line(TCase *tc);
void elm_code_test_parse(TCase *tc);
void elm_code_test_text(TCase *tc);
void elm_code_test_widget(TCase *tc);
void elm_code_test_widget_text(TCase *tc);
void elm_code_test_widget_selection(TCase *tc);
void elm_code_test_widget_undo(TCase *tc);
#endif /* _EDLM_CODE_SUITE_H */

View File

@ -135,6 +135,7 @@ elm_public_eolian_files = \
lib/elementary/elm_progressbar_internal_part.eo \
lib/elementary/elm_popup_internal_part.eo \
lib/elementary/elm_scroller_internal_part.eo \
lib/elementary/elm_code_widget.eo \
$(NULL)
# Legacy classes - not part of public EO API
@ -252,7 +253,16 @@ includesunstable_HEADERS = \
lib/elementary/elm_widget_thumb.h \
lib/elementary/elm_widget_toolbar.h \
lib/elementary/elm_widget_video.h \
lib/elementary/elm_widget_web.h
lib/elementary/elm_widget_web.h \
lib/elementary/elm_code.h \
lib/elementary/elm_code_widget_legacy.h \
lib/elementary/elm_code_widget_selection.h \
lib/elementary/elm_code_diff_widget.h \
lib/elementary/elm_code_common.h \
lib/elementary/elm_code_line.h \
lib/elementary/elm_code_text.h \
lib/elementary/elm_code_file.h \
lib/elementary/elm_code_parse.h
includesunstabledir = $(includedir)/elementary-@VMAJ@
nodist_includesunstable_HEADERS = \
@ -562,6 +572,16 @@ lib_elementary_libelementary_la_SOURCES = \
lib/elementary/elm_check.c \
lib/elementary/elm_clock.c \
lib/elementary/elm_cnp.c \
lib/elementary/elm_code_line.c \
lib/elementary/elm_code_text.c \
lib/elementary/elm_code_file.c \
lib/elementary/elm_code_parse.c \
lib/elementary/elm_code_widget_selection.c \
lib/elementary/elm_code_widget.c \
lib/elementary/elm_code_diff_widget.c \
lib/elementary/elm_code.c \
lib/elementary/elm_code_private.h \
lib/elementary/elm_code_widget_private.h \
lib/elementary/elm_colorselector.c \
lib/elementary/elm_color_class.c \
lib/elementary/elc_combobox.c \
@ -1214,6 +1234,11 @@ edje_external_elementary_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
edje_external_elementary_module_la_LIBTOOLFLAGS = --tag=disable-static
### Tests
EXTRA_DIST += \
tests/elementary/testfile.txt \
tests/elementary/testfile-windows.txt \
tests/elementary/testfile-withblanks.txt \
tests/elementary/testdiff.diff
if EFL_ENABLE_TESTS
@ -1291,12 +1316,24 @@ tests_elementary_elm_suite_SOURCES = \
tests/elementary/elm_test_panes.c \
tests/elementary/elm_test_slideshow.c \
tests/elementary/elm_test_spinner.c \
tests/elementary/elm_test_plug.c
tests/elementary/elm_test_plug.c \
tests/elementary/elm_code_file_test_load.c \
tests/elementary/elm_code_file_test_memory.c \
tests/elementary/elm_code_test_basic.c \
tests/elementary/elm_code_test_line.c \
tests/elementary/elm_code_test_parse.c \
tests/elementary/elm_code_test_text.c \
tests/elementary/elm_code_test_widget.c \
tests/elementary/elm_code_test_widget_text.c \
tests/elementary/elm_code_test_widget_selection.c \
tests/elementary/elm_code_test_widget_undo.c
tests_elementary_elm_suite_CPPFLAGS = \
-DTESTS_BUILD_DIR=\"${top_builddir}/src/tests/elementary\" \
-DTESTS_SRC_DIR=\"${top_srcdir}/src/tests/elementary\" \
-DELM_IMAGE_DATA_DIR=\"${top_srcdir}/data/elementary\" \
-DELM_TEST_DATA_DIR=\"${abs_top_builddir}/data/elementary\" \
-DPACKAGE_DATA_DIR=\"${abs_top_builddir}/data/elementary\" \
-I$(top_srcdir)/src/lib/elementary \
-I$(top_builddir)/src/lib/elementary \
@CHECK_CFLAGS@ \
@ -1339,4 +1376,7 @@ tests/elementary/elm_suite.h \
tests/elementary/elm_test_helper.h \
lib/elementary/Makefile.am \
lib/elementary/Makefile.in \
lib/elementary/Elementary.h.in
lib/elementary/Elementary.h.in \
lib/elementary/elm_code_widget_text.c \
lib/elementary/elm_code_widget_undo.c

View File

@ -202,6 +202,7 @@ EAPI extern Elm_Version *elm_version;
#include <elm_check.h>
#include <elm_clock.h>
#include <elm_cnp.h>
#include <elm_code.h>
#include <elm_colorselector.h>
#include <elm_color_class.h>
#include <elm_conform.h>

View File

@ -1,11 +1,11 @@
#ifdef HAVE_CONFIG
# include "config.h"
# include "elementary_config.h"
#endif
#include <Eo.h>
#include <Evas.h>
#include "Elm_Code.h"
#include "Elementary.h"
#include "elm_code_private.h"

View File

@ -1,46 +1,14 @@
#ifndef ELM_CODE_H_
# define ELM_CODE_H_
#include <Eina.h>
#include <Eo.h>
#include <Elementary.h>
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include <elm_widget.h>
#ifdef EAPI
# undef EAPI
#endif
#ifdef _WIN32
# ifdef EFL_ELM_CODE_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# endif /* ! EFL_ELM_CODE_BUILD */
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif /* ! _WIN32 */
#include "elm_code_common.h"
#include "elm_code_line.h"
#include "elm_code_text.h"
#include "elm_code_file.h"
#include "elm_code_parse.h"
#include "widget/elm_code_widget.eo.h"
#include "widget/elm_code_widget_legacy.h"
#include "widget/elm_code_widget_selection.h"
#include "elm_code_widget.eo.h"
#include "elm_code_widget_legacy.h"
#include "elm_code_widget_selection.h"
#include "elm_code_diff_widget.h"
#ifdef __cplusplus

View File

@ -1,8 +1,8 @@
#ifdef HAVE_CONFIG
# include "config.h"
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include "Elm_Code.h"
#include "Elementary.h"
#include "elm_code_private.h"

View File

@ -1,8 +1,8 @@
#ifdef HAVE_CONFIG
# include "config.h"
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include "Elm_Code.h"
#include "Elementary.h"
#include "elm_code_private.h"
@ -319,4 +319,3 @@ EAPI Elm_Code_Line *elm_code_file_line_get(Elm_Code_File *file, unsigned int num
{
return eina_list_nth(file->lines, number - 1);
}

View File

@ -1,8 +1,8 @@
#ifdef HAVE_CONFIG
# include "config.h"
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include "Elm_Code.h"
#include "Elementary.h"
#include "elm_code_private.h"

View File

@ -1,8 +1,8 @@
#ifdef HAVE_CONFIG
# include "config.h"
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include "Elm_Code.h"
#include "Elementary.h"
#include "elm_code_private.h"

View File

@ -1,8 +1,8 @@
#ifdef HAVE_CONFIG
# include "config.h"
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include "Elm_Code.h"
#include "Elementary.h"
#include "elm_code_private.h"

View File

@ -1,8 +1,11 @@
#ifdef HAVE_CONFIG
# include "config.h"
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include "Elm_Code.h"
#include <Elementary.h>
#include "elm_priv.h"
#include "elm_code_private.h"
#include "elm_code_widget_private.h"

View File

@ -1,6 +1,7 @@
import evas_types;
import edje_types;
import elm_interface_scrollable;
import elm_general;
struct @extern Elm_Code; /* The main interface currently defined in code */
struct @extern Elm_Code_Line; /* Parts of the interface currently defined in code */

View File

@ -10,4 +10,4 @@
*/
EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code);
#include "widget/elm_code_widget.eo.legacy.h"
#include "elm_code_widget.eo.legacy.h"

View File

@ -1,8 +1,8 @@
#ifdef HAVE_CONFIG
# include "config.h"
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include "Elm_Code.h"
#include "Elementary.h"
#include "elm_code_widget_private.h"

View File

@ -1,8 +1,8 @@
#ifdef HAVE_CONFIG
# include "config.h"
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include "Elm_Code.h"
#include "Elementary.h"
#include "elm_code_widget_private.h"

View File

@ -1,8 +1,8 @@
#ifdef HAVE_CONFIG
# include "config.h"
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include "Elm_Code.h"
#include "Elementary.h"
#include "elm_code_widget_private.h"

View File

@ -1,16 +1,20 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "elementary_config.h"
#endif
#include "elm_code_suite.h"
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "elm_suite.h"
#include "Elementary.h"
START_TEST (elm_code_file_load)
{
char *path = TESTS_DIR "testfile.txt";
char *path = TESTS_SRC_DIR "/testfile.txt";
char real[EINA_PATH_MAX];
Elm_Code_File *file;
Elm_Code *code;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_open(code, path);
realpath(path, real);
@ -19,51 +23,58 @@ START_TEST (elm_code_file_load)
ck_assert_str_eq(real, elm_code_file_path_get(file));
elm_code_file_close(file);
elm_code_free(code);
elm_shutdown();
}
END_TEST
START_TEST (elm_code_file_load_lines)
{
char *path = TESTS_DIR "testfile.txt";
char *path = TESTS_SRC_DIR "/testfile.txt";
Elm_Code_File *file;
Elm_Code *code;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_open(code, path);
ck_assert_uint_eq(4, elm_code_file_lines_get(file));
elm_code_file_close(file);
elm_code_free(code);
elm_shutdown();
}
END_TEST
START_TEST (elm_code_file_load_blank_lines)
{
char *path = TESTS_DIR "testfile-withblanks.txt";
char *path = TESTS_SRC_DIR "/testfile-withblanks.txt";
Elm_Code_File *file;
Elm_Code *code;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_open(code, path);
ck_assert_uint_eq(8, elm_code_file_lines_get(file));
elm_code_file_close(file);
elm_code_free(code);
elm_shutdown();
}
END_TEST
START_TEST (elm_code_file_load_windows)
{
char *path = TESTS_DIR "testfile-windows.txt";
char *path = TESTS_SRC_DIR "/testfile-windows.txt";
Elm_Code_File *file;
Elm_Code *code;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_open(code, path);
ck_assert_uint_eq(4, elm_code_file_lines_get(file));
elm_code_file_close(file);
elm_code_free(code);
elm_shutdown();
}
END_TEST
@ -81,10 +92,11 @@ static void _assert_line_content_eq(const char *content, Elm_Code_Line *line)
START_TEST (elm_code_file_load_content)
{
char *path = TESTS_DIR "testfile.txt";
char *path = TESTS_SRC_DIR "/testfile.txt";
Elm_Code_File *file;
Elm_Code *code;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_open(code, path);
@ -92,16 +104,18 @@ START_TEST (elm_code_file_load_content)
_assert_line_content_eq("another line", elm_code_file_line_get(file, 4));
elm_code_file_close(file);
elm_code_free(code);
elm_shutdown();
}
END_TEST
START_TEST (elm_code_file_line_ending_unix)
{
char *path = TESTS_DIR "testfile.txt";
char *path = TESTS_SRC_DIR "/testfile.txt";
Elm_Code_File *file;
Elm_Code *code;
short len;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_open(code, path);
@ -111,16 +125,18 @@ START_TEST (elm_code_file_line_ending_unix)
elm_code_file_close(file);
elm_code_free(code);
elm_shutdown();
}
END_TEST
START_TEST (elm_code_file_line_ending_windows)
{
char *path = TESTS_DIR "testfile-windows.txt";
char *path = TESTS_SRC_DIR "/testfile-windows.txt";
Elm_Code_File *file;
Elm_Code *code;
short len;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_open(code, path);
@ -130,6 +146,7 @@ START_TEST (elm_code_file_line_ending_windows)
elm_code_file_close(file);
elm_code_free(code);
elm_shutdown();
}
END_TEST
@ -143,4 +160,3 @@ void elm_code_file_test_load(TCase *tc)
tcase_add_test(tc, elm_code_file_line_ending_unix);
tcase_add_test(tc, elm_code_file_line_ending_windows);
}

View File

@ -1,13 +1,17 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "elementary_config.h"
#endif
#include "elm_code_suite.h"
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "elm_suite.h"
#include "Elementary.h"
START_TEST (elm_code_file_memory_lines)
{
Elm_Code *code;
elm_init(1, NULL);
code = elm_code_create();
ck_assert_uint_eq(0, elm_code_file_lines_get(code->file));
@ -15,6 +19,7 @@ START_TEST (elm_code_file_memory_lines)
ck_assert_uint_eq(1, elm_code_file_lines_get(code->file));
elm_code_free(code);
elm_shutdown();
}
END_TEST
@ -24,6 +29,7 @@ START_TEST (elm_code_file_memory_tokens)
Elm_Code_Line *line;
Elm_Code *code;
elm_init(1, NULL);
code = elm_code_create();
file = code->file;
elm_code_file_line_append(file, "a line", 6, NULL);
@ -32,6 +38,7 @@ START_TEST (elm_code_file_memory_tokens)
elm_code_line_token_add(line, 2, 5, 1, ELM_CODE_TOKEN_TYPE_COMMENT);
ck_assert_uint_eq(1, eina_list_count(line->tokens));
elm_code_free(code);
elm_shutdown();
}
END_TEST
@ -40,4 +47,3 @@ void elm_code_file_test_memory(TCase *tc)
tcase_add_test(tc, elm_code_file_memory_lines);
tcase_add_test(tc, elm_code_file_memory_tokens);
}

View File

@ -1,19 +1,24 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "elementary_config.h"
#endif
#include "elm_code_suite.h"
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "elm_suite.h"
#include "Elementary.h"
START_TEST (elm_code_create_test)
{
char *path = "elm_code/src/tests/testfile.txt";
char *path = TESTS_SRC_DIR "/testfile.txt";
Elm_Code *code;
elm_init(1, NULL);
code = elm_code_create();
elm_code_file_open(code, path);
ck_assert(!!code);
elm_code_free(code);
elm_shutdown();
}
END_TEST
@ -21,4 +26,3 @@ void elm_code_test_basic(TCase *tc)
{
tcase_add_test(tc, elm_code_create_test);
}

View File

@ -1,8 +1,11 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "elementary_config.h"
#endif
#include "elm_code_suite.h"
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "elm_suite.h"
#include "Elementary.h"
START_TEST (elm_code_line_create_test)
{
@ -10,6 +13,7 @@ START_TEST (elm_code_line_create_test)
Elm_Code_File *file;
Elm_Code_Line *line;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_new(code);
@ -19,6 +23,7 @@ START_TEST (elm_code_line_create_test)
ck_assert(!!line);
elm_code_free(code);
elm_shutdown();
}
END_TEST
@ -28,6 +33,7 @@ START_TEST (elm_code_line_token_count_test)
Elm_Code_File *file;
Elm_Code_Line *line;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_new(code);
@ -41,6 +47,7 @@ START_TEST (elm_code_line_token_count_test)
ck_assert_int_eq(0, eina_list_count(line->tokens));
elm_code_free(code);
elm_shutdown();
}
END_TEST
@ -50,6 +57,7 @@ START_TEST (elm_code_line_split_test)
Elm_Code_File *file;
Elm_Code_Line *line, *newline;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_new(code);
@ -63,6 +71,7 @@ START_TEST (elm_code_line_split_test)
newline = elm_code_file_line_get(file, 2);
ck_assert_int_eq(5, line->length);
ck_assert_int_eq(5, newline->length);
elm_shutdown();
}
END_TEST
@ -72,4 +81,3 @@ void elm_code_test_line(TCase *tc)
tcase_add_test(tc, elm_code_line_token_count_test);
tcase_add_test(tc, elm_code_line_split_test);
}

View File

@ -1,8 +1,11 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "elementary_config.h"
#endif
#include "elm_code_suite.h"
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "elm_suite.h"
#include "Elementary.h"
#include "elm_code_parse.h"
static int line_calls, file_calls;
@ -25,6 +28,7 @@ START_TEST (elm_code_parse_hook_memory_test)
line_calls = 0;
file_calls = 0;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_new(code);
@ -35,6 +39,7 @@ START_TEST (elm_code_parse_hook_memory_test)
ck_assert_int_eq(0, file_calls);
elm_code_free(code);
elm_shutdown();
}
END_TEST
@ -42,11 +47,12 @@ START_TEST (elm_code_parse_hook_file_test)
{
Elm_Code *code;
Elm_Code_File *file;
char *path = TESTS_DIR "testfile.txt";
char *path = TESTS_SRC_DIR "testfile.txt";
line_calls = 0;
file_calls = 0;
elm_init(1, NULL);
code = elm_code_create();
elm_code_parser_add(code, _parser_line_callback, _parser_file_callback, NULL);
@ -57,6 +63,7 @@ START_TEST (elm_code_parse_hook_file_test)
elm_code_file_close(file);
elm_code_free(code);
elm_shutdown();
}
END_TEST
@ -66,6 +73,7 @@ START_TEST (elm_code_parse_todo_test)
Elm_Code_File *file;
Elm_Code_Line *line;
elm_init(1, NULL);
elm_code_init();
code = elm_code_create();
@ -82,6 +90,7 @@ START_TEST (elm_code_parse_todo_test)
elm_code_line_text_set(line, "TOFIX", 5);
ck_assert_int_eq(ELM_CODE_STATUS_TYPE_DEFAULT, line->status);
elm_code_shutdown();
elm_shutdown();
}
END_TEST
@ -91,4 +100,3 @@ void elm_code_test_parse(TCase *tc)
tcase_add_test(tc, elm_code_parse_hook_file_test);
tcase_add_test(tc, elm_code_parse_todo_test);
}

View File

@ -1,8 +1,11 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "elementary_config.h"
#endif
#include "elm_code_suite.h"
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "elm_suite.h"
#include "Elementary.h"
#include "elm_code_text.h"
START_TEST (elm_code_text_get_test)
@ -11,12 +14,14 @@ START_TEST (elm_code_text_get_test)
Elm_Code_File *file;
Elm_Code_Line *line;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_new(code);
elm_code_file_line_append(file, "test", 4, NULL);
line = elm_code_file_line_get(file, 1);
ck_assert_str_eq("test", elm_code_line_text_get(line, NULL));
elm_shutdown();
}
END_TEST
@ -26,6 +31,7 @@ START_TEST (elm_code_text_insert_test)
Elm_Code_File *file;
Elm_Code_Line *line;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_new(code);
@ -34,6 +40,7 @@ START_TEST (elm_code_text_insert_test)
elm_code_line_text_insert(line, 4, "ing", 3);
ck_assert_str_eq("testing", elm_code_line_text_get(line, NULL));
elm_shutdown();
}
END_TEST
@ -43,6 +50,7 @@ START_TEST (elm_code_text_contains_test)
Elm_Code_File *file;
Elm_Code_Line *line;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_new(code);
@ -54,6 +62,7 @@ START_TEST (elm_code_text_contains_test)
ck_assert_int_eq(EINA_TRUE, elm_code_line_text_contains(line, "a t"));
ck_assert_int_eq(EINA_TRUE, elm_code_line_text_contains(line, "..."));
elm_shutdown();
}
END_TEST
@ -63,6 +72,7 @@ START_TEST (elm_code_text_strpos_test)
Elm_Code_File *file;
Elm_Code_Line *line;
elm_init(1, NULL);
code = elm_code_create();
file = elm_code_file_new(code);
@ -78,6 +88,7 @@ START_TEST (elm_code_text_strpos_test)
ck_assert_int_eq(0, elm_code_line_text_strpos(line, "a t", 0));
ck_assert_int_eq(ELM_CODE_TEXT_NOT_FOUND, elm_code_line_text_strpos(line, "a t", 2));
ck_assert_int_eq(13, elm_code_line_text_strpos(line, "...", 0));
elm_shutdown();
}
END_TEST
@ -87,10 +98,12 @@ START_TEST (elm_code_text_newline_position_test)
const char *unixtext = "a test\nwith newline";
const char *wintext = "a windows\r\nnewline";
elm_init(1, NULL);
ck_assert_int_eq(6, elm_code_text_newlinenpos(unixtext, strlen(unixtext), &nllen));
ck_assert_int_eq(1, nllen);
ck_assert_int_eq(9, elm_code_text_newlinenpos(wintext, strlen(wintext), &nllen));
ck_assert_int_eq(2, nllen);
elm_shutdown();
}
END_TEST
@ -98,6 +111,7 @@ START_TEST (elm_code_text_leading_whitespace_test)
{
const char *text;
elm_init(1, NULL);
text = "testing";
ck_assert_int_eq(0, elm_code_text_leading_whitespace_length(text, strlen(text)));
@ -109,6 +123,7 @@ START_TEST (elm_code_text_leading_whitespace_test)
text = " \t mix";
ck_assert_int_eq(3, elm_code_text_leading_whitespace_length(text, strlen(text)));
elm_shutdown();
}
END_TEST
@ -116,6 +131,7 @@ START_TEST (elm_code_text_trailing_whitespace_test)
{
const char *text;
elm_init(1, NULL);
text = "testing";
ck_assert_int_eq(0, elm_code_text_trailing_whitespace_length(text, strlen(text)));
@ -127,6 +143,7 @@ START_TEST (elm_code_text_trailing_whitespace_test)
text = "mix \t ";
ck_assert_int_eq(3, elm_code_text_trailing_whitespace_length(text, strlen(text)));
elm_shutdown();
}
END_TEST
@ -134,6 +151,7 @@ START_TEST (elm_code_text_is_whitespace_test)
{
const char *text;
elm_init(1, NULL);
text = " ";
ck_assert_int_eq(1, elm_code_text_is_whitespace(text, strlen(text)));
@ -142,6 +160,7 @@ START_TEST (elm_code_text_is_whitespace_test)
text = " . ";
ck_assert_int_eq(0, elm_code_text_is_whitespace(text, strlen(text)));
elm_shutdown();
}
END_TEST

View File

@ -1,10 +1,12 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "elementary_config.h"
#endif
#include "elm_code_suite.h"
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "widget/elm_code_widget.c"
#include "elm_suite.h"
#include "Elementary.h"
#include "elm_code_widget.c"
static void _assert_cell_type(Evas_Textgrid_Cell cell, Elm_Code_Token_Type type, int id)
{
@ -89,4 +91,3 @@ void elm_code_test_widget(TCase *tc)
tcase_add_test(tc, elm_code_widget_construct);
tcase_add_test(tc, elm_code_widget_construct_nocode);
}

View File

@ -1,12 +1,13 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "elementary_config.h"
#endif
#include "elm_code_suite.h"
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "elm_suite.h"
#include "Elementary.h"
#include "elm_code_widget_private.h"
#include "widget/elm_code_widget_selection.h"
#include "elm_code_widget_selection.h"
START_TEST (elm_code_test_widget_selection_set)
{
@ -502,6 +503,7 @@ START_TEST (elm_code_test_widget_selection_select_line)
selection = elm_code_widget_selection_text_get(widget);
ck_assert_str_eq("line2", selection);
free(selection);
elm_shutdown();
}
END_TEST
@ -536,6 +538,7 @@ START_TEST (elm_code_test_widget_selection_select_word)
selection = elm_code_widget_selection_text_get(widget);
ck_assert_str_eq("stuff", selection);
free(selection);
elm_shutdown();
}
END_TEST
@ -574,6 +577,7 @@ START_TEST (elm_code_test_widget_selection_select_word_punctuation)
selection = elm_code_widget_selection_text_get(widget);
ck_assert_str_eq("mark", selection);
free(selection);
elm_shutdown();
}
END_TEST
@ -612,6 +616,7 @@ START_TEST (elm_code_test_widget_selection_select_word_symbols)
selection = elm_code_widget_selection_text_get(widget);
ck_assert_str_eq("braces", selection);
free(selection);
elm_shutdown();
}
END_TEST
@ -636,4 +641,3 @@ void elm_code_test_widget_selection(TCase *tc)
tcase_add_test(tc, elm_code_test_widget_selection_select_word_punctuation);
tcase_add_test(tc, elm_code_test_widget_selection_select_word_symbols);
}

View File

@ -1,8 +1,11 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "elementary_config.h"
#endif
#include "elm_code_suite.h"
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "elm_suite.h"
#include "Elementary.h"
START_TEST (elm_code_test_widget_text_tab_width)
{
@ -48,6 +51,7 @@ START_TEST (elm_code_test_widget_text_position)
ck_assert_int_eq(2, elm_code_widget_line_text_position_for_column_get(widget, line, 9));
ck_assert_int_eq(1, elm_code_widget_line_text_position_for_column_get(widget, line, 7));
elm_shutdown();
}
END_TEST
@ -56,4 +60,3 @@ void elm_code_test_widget_text(TCase *tc)
tcase_add_test(tc, elm_code_test_widget_text_tab_width);
tcase_add_test(tc, elm_code_test_widget_text_position);
}

View File

@ -1,9 +1,11 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "elementary_config.h"
#endif
#include "elm_code_suite.h"
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "elm_suite.h"
#include "Elementary.h"
#include "elm_code_widget_private.h"
START_TEST (elm_code_test_widget_undo_text_insert)
@ -161,4 +163,3 @@ void elm_code_test_widget_undo(TCase *tc)
tcase_add_test(tc, elm_code_test_widget_undo_newline);
tcase_add_test(tc, elm_code_test_widget_undo_delete);
}

View File

@ -71,6 +71,15 @@ static const Efl_Test_Case etc[] = {
{ "elm_slideshow", elm_test_slideshow},
{ "elm_spinner", elm_test_spinner},
{ "elm_plug", elm_test_plug},
{ "file_load", elm_code_file_test_load },
{ "file_memory", elm_code_file_test_memory },
{ "parse", elm_code_test_parse },
{ "text", elm_code_test_text },
{ "basic", elm_code_test_basic },
{ "widget", elm_code_test_widget },
{ "widget_text", elm_code_test_widget_text },
{ "widget_selection", elm_code_test_widget_selection },
{ "widget_undo", elm_code_test_widget_undo },
{ NULL, NULL }
};

View File

@ -69,4 +69,15 @@ void elm_test_slideshow(TCase *tc);
void elm_test_spinner(TCase *tc);
void elm_test_plug(TCase *tc);
void elm_code_file_test_load(TCase *tc);
void elm_code_file_test_memory(TCase *tc);
void elm_code_test_basic(TCase *tc);
void elm_code_test_line(TCase *tc);
void elm_code_test_parse(TCase *tc);
void elm_code_test_text(TCase *tc);
void elm_code_test_widget(TCase *tc);
void elm_code_test_widget_text(TCase *tc);
void elm_code_test_widget_selection(TCase *tc);
void elm_code_test_widget_undo(TCase *tc);
#endif /* _ELM_SUITE_H */

View File

@ -3,6 +3,19 @@
#include <Eina.h>
#define ck_assert_strn_eq(s1, s2, len) \
{ \
char expected[len+1], actual[len+1]; \
\
strncpy(expected, s1, len); \
expected[len] = '\0'; \
strncpy(actual, s2, len); \
actual[len] = '\0'; \
\
ck_assert_str_eq(expected, actual); \
}
Eina_Bool elm_test_helper_wait_flag(double in, Eina_Bool *done);
#endif /* _ELM_TEST_HELPER_H */