Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
- name: Test
env:
XDG_RUNTIME_DIR: /tmp
GSETTINGS_BACKEND: keyfile
run: |
glib-compile-schemas src/setup --targetdir=build/bin
weston --no-config --socket=wl-headless --backend=headless &
Expand All @@ -54,7 +53,6 @@ jobs:
- name: Test
env:
XDG_RUNTIME_DIR: /tmp
GSETTINGS_BACKEND: keyfile
run: |
weston --no-config --socket=wl-headless --backend=headless &
WAYLAND_DISPLAY=wl-headless meson test -C build --print-errorlogs
Expand Down Expand Up @@ -91,7 +89,6 @@ jobs:
- name: Test
env:
XDG_RUNTIME_DIR: /tmp
GSETTINGS_BACKEND: keyfile
LLVM_PROFILE_FILE: "default_%p_%m.profraw"
run: |
source "$HOME/.cargo/env"
Expand Down Expand Up @@ -123,7 +120,6 @@ jobs:
- name: Test
env:
XDG_RUNTIME_DIR: /tmp
GSETTINGS_BACKEND: keyfile
run: |
weston --no-config --socket=wl-headless --backend=headless &
WAYLAND_DISPLAY=wl-headless meson test -C build --print-errorlogs
Expand Down
19 changes: 0 additions & 19 deletions src/ibus-chewing-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,6 @@
#include <gtk/gtk.h>
#include <ibus.h>

static const GEnumValue _engine_flag_values[] = {
{ENGINE_FLAG_INITIALIZED, (char *)"ENGINE_FLAG_INITIALIZED", (char *)"initialized"},
{ENGINE_FLAG_ENABLED, (char *)"ENGINE_FLAG_ENABLED", (char *)"enabled"},
{ENGINE_FLAG_FOCUS_IN, (char *)"ENGINE_FLAG_FOCUS_IN", (char *)"focus-in"},
{ENGINE_FLAG_IS_PASSWORD, (char *)"ENGINE_FLAG_IS_PASSWORD", (char *)"is-password"},
{ENGINE_FLAG_PROPERTIES_REGISTERED, (char *)"ENGINE_FLAG_PROPERTIES_REGISTERED",
(char *)"properties-registered"},
{0, NULL, NULL}};

GType engine_flag_get_type(void) {
static GType type = 0;

if G_UNLIKELY (type == 0)
type = g_enum_register_static("EngineFlag", _engine_flag_values);
return type;
}

static ChewingKbType kb_type_get_index(const gchar *kb_type) {
// The order of this list should match libchewing's KB enum
//
Expand Down Expand Up @@ -481,7 +464,6 @@ static void ibus_chewing_engine_init(IBusChewingEngine *self) {

ibus_chewing_engine_set_status_flag(self, ENGINE_FLAG_INITIALIZED);

#ifndef UNIT_TEST
g_autoptr(GSettings) settings = g_settings_new(QUOTE_ME(PROJECT_SCHEMA_ID));
g_autoptr(GSettings) ibus_settings = g_settings_new("org.freedesktop.ibus.general");

Expand All @@ -508,7 +490,6 @@ static void ibus_chewing_engine_init(IBusChewingEngine *self) {

g_settings_bind(ibus_settings, "use-system-keyboard-layout", self, "use-system-keyboard-layout",
G_SETTINGS_BIND_DEFAULT);
#endif

IBUS_CHEWING_LOG(DEBUG, "init() Done");
}
Expand Down
4 changes: 0 additions & 4 deletions src/ibus-chewing-engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#pragma once

#include "ibus-chewing-preedit.h"
#include "ibus-chewing-util.h"
#include <glib-object.h>
#include <glib.h>
#include <ibus.h>
Expand All @@ -37,8 +35,6 @@ typedef enum {
ENGINE_FLAG_IS_PASSWORD = 0x8,
ENGINE_FLAG_PROPERTIES_REGISTERED = 0x10
} EngineFlag;
#define ENGINE_TYPE_FLAG engine_flag_get_type()
GType engine_flag_get_type(void) G_GNUC_CONST;

// XXX not defined by ibus
G_DEFINE_AUTOPTR_CLEANUP_FUNC(IBusEngine, g_object_unref)
Expand Down
16 changes: 13 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ add_executable(ibus-chewing-preedit-test ibus-chewing-preedit-test.c
target_link_libraries(ibus-chewing-preedit-test common PkgConfig::GTK4)
add_test(NAME ibus-chewing-preedit
COMMAND gtester ${CMAKE_CURRENT_BINARY_DIR}/ibus-chewing-preedit-test)
set_tests_properties(ibus-chewing-preedit PROPERTIES
ENVIRONMENT "GSETTINGS_SCHEMA_DIR=${CMAKE_BINARY_DIR}/bin"
ENVIRONMENT "GSETTINGS_BACKEND=memory"
)

# ==================
add_executable(ibus-chewing-engine-test ibus-chewing-engine-test.c
Expand All @@ -38,14 +42,20 @@ target_link_libraries(ibus-chewing-engine-test common PkgConfig::GTK4)
add_test(NAME ibus-chewing-engine
COMMAND gtester ${CMAKE_CURRENT_BINARY_DIR}/ibus-chewing-engine-test)
set_tests_properties(ibus-chewing-engine PROPERTIES
ENVIRONMENT "GSETTINGS_SCHEMA_DIR=${CMAKE_BINARY_DIR}/bin")
ENVIRONMENT "GSETTINGS_SCHEMA_DIR=${CMAKE_BINARY_DIR}/bin"
ENVIRONMENT "GSETTINGS_BACKEND=memory"
)

# ==================
add_test(NAME ibus-setup-chewing
COMMAND ${CMAKE_BINARY_DIR}/bin/ibus-setup-chewing -q)
set_tests_properties(ibus-setup-chewing PROPERTIES
ENVIRONMENT "GSETTINGS_SCHEMA_DIR=${CMAKE_BINARY_DIR}/bin")
ENVIRONMENT "GSETTINGS_SCHEMA_DIR=${CMAKE_BINARY_DIR}/bin"
ENVIRONMENT "GSETTINGS_BACKEND=memory"
)
add_test(NAME ibus-setup-chewing-about
COMMAND ${CMAKE_BINARY_DIR}/bin/ibus-setup-chewing --about -q)
set_tests_properties(ibus-setup-chewing-about PROPERTIES
ENVIRONMENT "GSETTINGS_SCHEMA_DIR=${CMAKE_BINARY_DIR}/bin")
ENVIRONMENT "GSETTINGS_SCHEMA_DIR=${CMAKE_BINARY_DIR}/bin"
ENVIRONMENT "GSETTINGS_BACKEND=memory"
)
15 changes: 13 additions & 2 deletions test/ibus-chewing-engine-test.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "glib-object.h"
#include "ibus-chewing-engine-private.h"
#include "ibus-chewing-engine.h"
#include "test-util.h"
Expand Down Expand Up @@ -64,21 +65,31 @@ void focus_out_then_focus_in_with_aux_text_test() {
}

void focus_out_then_focus_in_with_aux_text_clean_buffer_on_test() {
engine = ibus_chewing_engine_new();

g_object_set(G_OBJECT(engine), "max-chi-symbol-len", 8, NULL);
g_object_set(G_OBJECT(engine), "clean-buffer-focus-out", TRUE, NULL);

focus_out_then_focus_in_with_aux_text_test();

g_object_unref(engine);
}

void focus_out_then_focus_in_with_aux_text_clean_buffer_off_test() {
engine = ibus_chewing_engine_new();

g_object_set(G_OBJECT(engine), "max-chi-symbol-len", 8, NULL);
g_object_set(G_OBJECT(engine), "clean-buffer-focus-out", FALSE, NULL);

focus_out_then_focus_in_with_aux_text_test();

g_object_unref(engine);
}

gint main(gint argc, gchar **argv) {
g_test_init(&argc, &argv, NULL);
mkdg_log_set_level(DEBUG);
engine = ibus_chewing_engine_new();

g_object_set(G_OBJECT(engine), "max-chi-symbol-len", 8, NULL);
TEST_RUN_THIS(focus_out_then_focus_in_with_aux_text_clean_buffer_off_test);
TEST_RUN_THIS(focus_out_then_focus_in_with_aux_text_clean_buffer_on_test);

Expand Down
1 change: 1 addition & 0 deletions test/ibus-chewing-preedit-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ void process_key_text_with_symbol_test() {

key_press_from_string("1j65j/4");
key_press_from_key_sym(IBUS_KEY_Down, 0);
key_press_from_key_sym(IBUS_KEY_Down, 0);
key_press_from_string("3");

key_press_from_key_sym(IBUS_KEY_less, IBUS_SHIFT_MASK);
Expand Down
49 changes: 31 additions & 18 deletions test/meson.build
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
test_c_args = ['-DUNIT_TEST']
inc = include_directories('../src', '../src/setup')

chewing_test_common_src = [
'../src/ibus-chewing-lookup-table.c',
]
chewing_test_common_src = ['../src/ibus-chewing-lookup-table.c']

chewing_test_common_dep = [chewing_dep, glib_dep, ibus_dep]

Expand All @@ -30,9 +28,12 @@ ibus_chewing_util_test = executable(
test(
'ibus-chewing-util',
ibus_chewing_util_test,
env: 'GSETTINGS_SCHEMA_DIR=@0@'.format(
meson.project_build_root() / 'src/setup',
),
env: [
'GSETTINGS_SCHEMA_DIR=@0@'.format(
meson.project_build_root() / 'src/setup',
),
'GSETTINGS_BACKEND=memory',
],
protocol: 'tap',
)

Expand All @@ -54,9 +55,12 @@ ibus_chewing_preedit_test = executable(
test(
'ibus-chewing-preedit',
ibus_chewing_preedit_test,
env: 'GSETTINGS_SCHEMA_DIR=@0@'.format(
meson.project_build_root() / 'src/setup',
),
env: [
'GSETTINGS_SCHEMA_DIR=@0@'.format(
meson.project_build_root() / 'src/setup',
),
'GSETTINGS_BACKEND=memory',
],
protocol: 'tap',
)

Expand All @@ -79,28 +83,37 @@ ibus_chewing_engine_test = executable(
test(
'ibus-chewing-engine',
ibus_chewing_engine_test,
env: 'GSETTINGS_SCHEMA_DIR=@0@'.format(
meson.project_build_root() / 'src/setup',
),
env: [
'GSETTINGS_SCHEMA_DIR=@0@'.format(
meson.project_build_root() / 'src/setup',
),
'GSETTINGS_BACKEND=memory',
],
protocol: 'tap',
)

test(
'ibus-setup-chewing',
ibus_setup_chewing,
args: '-q',
env: 'GSETTINGS_SCHEMA_DIR=@0@'.format(
meson.project_build_root() / 'src/setup',
),
env: [
'GSETTINGS_SCHEMA_DIR=@0@'.format(
meson.project_build_root() / 'src/setup',
),
'GSETTINGS_BACKEND=memory',
],
is_parallel: false,
)

test(
'ibus-setup-chewing-about',
ibus_setup_chewing,
args: ['--about', '-q'],
env: 'GSETTINGS_SCHEMA_DIR=@0@'.format(
meson.project_build_root() / 'src/setup',
),
env: [
'GSETTINGS_SCHEMA_DIR=@0@'.format(
meson.project_build_root() / 'src/setup',
),
'GSETTINGS_BACKEND=memory',
],
is_parallel: false,
)