char *path;
FILE *file;
- path = test_get_path("compose/en_US.UTF-8/Compose");
+ path = test_get_path("locale/en_US.UTF-8/Compose");
file = fopen(path, "rb");
assert(file);
free(path);
char *path;
FILE *file;
- path = test_get_path("compose/en_US.UTF-8/Compose");
+ path = test_get_path("locale/en_US.UTF-8/Compose");
file = fopen(path, "rb");
assert(file);
free(path);
struct xkb_compose_table *table;
char *path;
- path = test_get_path("compose/en_US.UTF-8/Compose");
+ path = test_get_path("locale/en_US.UTF-8/Compose");
setenv("XCOMPOSEFILE", path, 1);
free(path);
XKB_COMPOSE_COMPILE_NO_FLAGS);
assert(table);
+ unsetenv("XCOMPOSEFILE");
+
assert(test_compose_seq(table,
XKB_KEY_dead_tilde, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSING, "", XKB_KEY_NoSymbol,
XKB_KEY_space, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSED, "~", XKB_KEY_asciitilde,
}
static void
+test_from_locale(struct xkb_context *ctx)
+{
+ struct xkb_compose_table *table;
+ char *path;
+
+ path = test_get_path("locale");
+ setenv("XLOCALEDIR", path, 1);
+ free(path);
+
+ /* Direct directory name match. */
+ table = xkb_compose_table_new_from_locale(ctx, "en_US.UTF-8",
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ assert(table);
+ xkb_compose_table_unref(table);
+
+ /* Direct locale name match. */
+ table = xkb_compose_table_new_from_locale(ctx, "C.UTF-8",
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ assert(table);
+ xkb_compose_table_unref(table);
+
+ /* Alias. */
+ table = xkb_compose_table_new_from_locale(ctx, "univ.utf8",
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ assert(table);
+ xkb_compose_table_unref(table);
+
+ /* Special case - C. */
+ table = xkb_compose_table_new_from_locale(ctx, "C",
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ assert(table);
+ xkb_compose_table_unref(table);
+
+ /* Bogus - not found. */
+ table = xkb_compose_table_new_from_locale(ctx, "blabla",
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ assert(!table);
+
+ unsetenv("XLOCALEDIR");
+}
+
+
+static void
test_modifier_syntax(struct xkb_context *ctx)
{
const char *table_string;
{
char *path, *table_string;
- path = test_get_path("compose/en_US.UTF-8/Compose");
+ path = test_get_path("locale/en_US.UTF-8/Compose");
assert(path);
/* We don't have a mechanism to change the include paths like we
free(table_string);
}
+static void
+test_override(struct xkb_context *ctx)
+{
+ const char *table_string = "<dead_circumflex> <dead_circumflex> : \"foo\" X\n"
+ "<dead_circumflex> <e> : \"bar\" Y\n"
+ "<dead_circumflex> <dead_circumflex> <e> : \"baz\" Z\n";
+
+ assert(test_compose_seq_buffer(ctx, table_string,
+ /* Comes after - does override. */
+ XKB_KEY_dead_circumflex, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSING, "", XKB_KEY_NoSymbol,
+ XKB_KEY_dead_circumflex, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSING, "", XKB_KEY_NoSymbol,
+ XKB_KEY_e, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSED, "baz", XKB_KEY_Z,
+
+ /* Override does not affect sibling nodes */
+ XKB_KEY_dead_circumflex, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSING, "", XKB_KEY_NoSymbol,
+ XKB_KEY_e, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSED, "bar", XKB_KEY_Y,
+
+ XKB_KEY_NoSymbol));
+}
+
int
main(int argc, char *argv[])
{
ctx = test_get_context(CONTEXT_NO_FLAG);
assert(ctx);
+ /*
+ * Ensure no environment variables but “top_srcdir” is set. This ensures
+ * that user Compose file paths are unset before the tests and set
+ * explicitely when necessary.
+ */
+#ifdef __linux__
+ const char *srcdir = getenv("top_srcdir");
+ clearenv();
+ setenv("top_srcdir", srcdir, 1);
+#else
+ unsetenv("XCOMPOSEFILE");
+ unsetenv("XDG_CONFIG_HOME");
+ unsetenv("HOME");
+ unsetenv("XLOCALEDIR");
+#endif
+
test_seqs(ctx);
test_conflicting(ctx);
test_XCOMPOSEFILE(ctx);
+ test_from_locale(ctx);
test_state(ctx);
test_modifier_syntax(ctx);
test_include(ctx);
+ test_override(ctx);
xkb_context_unref(ctx);
return 0;