mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-06 14:07:32 +00:00
Merge pull request #5884 from keymanapp/chore/linux/5613-unittests
chore(linux): fix failing ibus-keyman tests 🎫
This commit is contained in:
commit
16ebd7e653
7 changed files with 49 additions and 8 deletions
1
linux/ibus-keyman/.gitignore
vendored
1
linux/ibus-keyman/.gitignore
vendored
|
|
@ -7,3 +7,4 @@ src/print_kmp
|
|||
src/print_kmpdetails
|
||||
*.log
|
||||
*.trs
|
||||
.dirstamp
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@
|
|||
#define KEYMAN_DCONF_PATH "/desktop/ibus/keyman/options/"
|
||||
#define KEYMAN_DCONF_OPTIONS_KEY "options"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void ibus_keyman_init (void);
|
||||
GList *ibus_keyman_list_engines (void);
|
||||
IBusComponent *ibus_keyman_get_component (void);
|
||||
|
|
@ -109,4 +111,6 @@ void keyman_put_options_todconf
|
|||
gchar *option_key,
|
||||
gchar *option_value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -81,6 +81,10 @@ ibus_keyman_tests_SOURCES = \
|
|||
../../../common/core/desktop/tests/unit/kmx/kmx_test_source.cpp \
|
||||
../../../common/core/desktop/tests/unit/kmx/kmx_test_source.hpp \
|
||||
../src/keycodes.h \
|
||||
../src/keymanutil.c \
|
||||
../src/keymanutil.h \
|
||||
../src/kmpdetails.c \
|
||||
../src/kmpdetails.h \
|
||||
$(NULL)
|
||||
|
||||
ibus_keyman_tests_CFLAGS = \
|
||||
|
|
@ -94,6 +98,7 @@ ibus_keyman_tests_CFLAGS = \
|
|||
-I$(top_srcdir)/../../common/core/desktop/src/kmx \
|
||||
-I$(top_srcdir)/../../common/core/desktop/tests/unit/kmx \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_builddir)/src \
|
||||
$(NULL)
|
||||
|
||||
ibus_keyman_tests_CPPFLAGS = \
|
||||
|
|
@ -107,6 +112,7 @@ ibus_keyman_tests_CPPFLAGS = \
|
|||
-I$(top_srcdir)/../../common/core/desktop/src/kmx \
|
||||
-I$(top_srcdir)/../../common/core/desktop/tests/unit/kmx \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_builddir)/src \
|
||||
$(NULL)
|
||||
|
||||
ibus_keyman_tests_LDFLAGS = \
|
||||
|
|
|
|||
|
|
@ -932,6 +932,11 @@ static gboolean
|
|||
_delete_surrounding(IBusIMContext *ibusimcontext, gint offset_from_cursor, guint nchars) {
|
||||
// g_signal_emit(ibusimcontext, _signal_delete_surrounding_id, 0);
|
||||
if (offset_from_cursor < 0) {
|
||||
for (guint val = nchars;
|
||||
val <= ibusimcontext->text->len && (guint)ibusimcontext->text->str[ibusimcontext->text->len - val] >= 0x80;
|
||||
val++) {
|
||||
nchars = val;
|
||||
}
|
||||
g_string_erase(ibusimcontext->text, ibusimcontext->text->len - nchars, nchars);
|
||||
} else {
|
||||
g_string_erase(ibusimcontext->text, offset_from_cursor, nchars);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
BASEDIR=$(dirname $0)
|
||||
BASEDIR=$(realpath $(dirname $0))
|
||||
TESTDIR=${XDG_DATA_HOME:-$HOME/.local/share}/keyman/test_kmx
|
||||
|
||||
if [ "$DISPLAY" == ":0" ]; then
|
||||
|
|
@ -9,7 +9,14 @@ if [ "$DISPLAY" == ":0" ]; then
|
|||
fi
|
||||
|
||||
if [ ! -d $TESTDIR ]; then
|
||||
ln -sf $BASEDIR/../../../common/core/desktop/build/arch/debug/tests/unit/kmx $TESTDIR
|
||||
if [ -d $BASEDIR/../../../common/core/desktop/build/arch/debug ]; then
|
||||
ln -sf $(realpath $BASEDIR/../../../common/core/desktop/build/arch/debug/tests/unit/kmx) $TESTDIR
|
||||
elif [ -d $BASEDIR/../../../common/core/desktop/build/arch/release ]; then
|
||||
ln -sf $(realpath $BASEDIR/../../../common/core/desktop/build/arch/release/tests/unit/kmx) $TESTDIR
|
||||
else
|
||||
echo "Can't find kmx files in common/core/desktop/build/arch/*/tests/unit/kmx"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <string>
|
||||
#include "ibusimcontext.h"
|
||||
#include "keycodes.h"
|
||||
#include "keymanutil.h"
|
||||
#include "kmx_test_source.hpp"
|
||||
#include "testmodule.h"
|
||||
|
||||
|
|
@ -21,6 +22,11 @@ typedef struct {
|
|||
IBusIMContext *ibuscontext;
|
||||
} IBusKeymanTestsFixture;
|
||||
|
||||
typedef struct {
|
||||
char *test_name;
|
||||
char *test_path;
|
||||
} TestData;
|
||||
|
||||
static gboolean loaded = FALSE;
|
||||
static GdkWindow *window = NULL;
|
||||
static GMainLoop *thread_loop = NULL;
|
||||
|
|
@ -272,8 +278,9 @@ press_keys(IBusKeymanTestsFixture *fixture, km::tests::KmxTestSource & test_sour
|
|||
}
|
||||
|
||||
static void test_source(IBusKeymanTestsFixture *fixture, gconstpointer user_data) {
|
||||
auto sourcefile = string_format("%s.kmn", (char *)user_data);
|
||||
auto kmxfile = string_format("und:%s.kmx", (char*)user_data);
|
||||
auto data = (TestData*)user_data;
|
||||
auto sourcefile = string_format("%s.kmn", data->test_path);
|
||||
auto kmxfile = string_format("und:%s.kmx", data->test_path);
|
||||
|
||||
km::tests::KmxTestSource test_source;
|
||||
std::string keys = "";
|
||||
|
|
@ -282,6 +289,14 @@ static void test_source(IBusKeymanTestsFixture *fixture, gconstpointer user_data
|
|||
bool expected_beep = false;
|
||||
g_assert_cmpint(test_source.load_source(sourcefile.c_str(), keys, expected, context, options, expected_beep), ==, 0);
|
||||
|
||||
for (auto & option : options) {
|
||||
if (option.type == km::tests::KOT_INPUT) {
|
||||
auto key = g_utf16_to_utf8((gunichar2 *)option.key.c_str(), option.key.length(), NULL, NULL, NULL);
|
||||
auto value = g_utf16_to_utf8((gunichar2 *)option.value.c_str(), option.value.length(), NULL, NULL, NULL);
|
||||
keyman_put_options_todconf(data->test_name, data->test_name, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
switch_keyboard(fixture, kmxfile.c_str());
|
||||
|
||||
auto contextKeys = get_context_keys(context);
|
||||
|
|
@ -336,8 +351,11 @@ main(int argc, char *argv[]) {
|
|||
auto testname = g_string_new(NULL);
|
||||
g_string_append_printf(testname, "/%s", testfilebase);
|
||||
auto testfile = g_file_new_build_filename(directory, testfilebase, NULL);
|
||||
TestData testdata;
|
||||
testdata.test_name = filename;
|
||||
testdata.test_path = g_file_get_parse_name(testfile);
|
||||
g_test_add(
|
||||
testname->str, IBusKeymanTestsFixture, g_file_get_parse_name(testfile), ibus_keyman_tests_fixture_set_up, test_source,
|
||||
testname->str, IBusKeymanTestsFixture, &testdata, ibus_keyman_tests_fixture_set_up, test_source,
|
||||
ibus_keyman_tests_fixture_tear_down);
|
||||
g_object_unref(file);
|
||||
g_object_unref(testfile);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __TESTMODULE__
|
||||
#define __TESTMODULE__
|
||||
#ifndef __TESTMODULE_H__
|
||||
#define __TESTMODULE_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
@ -30,4 +30,4 @@ void test_module_unuse(GTypeModule* test_module);
|
|||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __TESTMODULE__ */
|
||||
#endif // __TESTMODULE_H__
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue