#include "xkbcommon/xkbregistry.h"
#include "utils.h"
+#include "test.h"
#define NO_VARIANT NULL
int rc;
FILE *fp;
- tmpdir = asprintf_safe("/tmp/%s.%d.XXXXXX", ruleset, iteration++);
- assert(tmpdir);
- assert(mkdtemp(tmpdir) == tmpdir);
+ char *template = asprintf_safe("%s.%d.XXXXXX", ruleset, iteration++);
+ assert(template != NULL);
+ tmpdir = test_maketempdir(template);
+ free(template);
+
+ free(test_makedir(tmpdir, "rules"));
- rc = snprintf_safe(buf, sizeof(buf), "%s/rules", tmpdir);
- assert(rc);
- rc = mkdir(buf, 0777);
- assert(rc == 0);
rc = snprintf_safe(buf, sizeof(buf), "%s/rules/%s.xml", tmpdir, ruleset);
assert(rc);
struct test_layout system_layouts[] = {
{"l1", NO_VARIANT, "lbrief1", "ldesc1"},
{"l1", "v1", "vbrief1", "vdesc1"},
+ {"l1", "v2", NULL, "vdesc2"},
{NULL},
};
struct test_option_group system_groups[] = {
assert(cmp_layouts(&system_layouts[1], l));
rxkb_layout_unref(l);
+ l = fetch_layout(ctx, "l1", "v2");
+ struct test_layout expected = {"l1", "v2", "lbrief1", "vdesc2"};
+ assert(cmp_layouts(&expected, l));
+ rxkb_layout_unref(l);
+
g = fetch_option_group(ctx, "grp1");
assert(cmp_option_groups(&system_groups[0], g, CMP_EXACT));
rxkb_option_group_unref(g);
{"l1", "v1", "vbrief1", "vdesc1",
.iso639 = {"efg"},
.iso3166 = {"yz"}},
+ {"l2", NO_VARIANT, "lbrief1", "ldesc1",
+ .iso639 = { "hij", "klm" },
+ .iso3166 = { "op", "qr" }},
+ {"l2", "v2", "lbrief1", "ldesc1",
+ .iso639 = { NULL }, /* inherit from parent */
+ .iso3166 = { NULL }}, /* inherit from parent */
{NULL},
};
struct test_option_group system_groups[] = {
};
struct rxkb_context *ctx;
struct rxkb_layout *l;
+ struct rxkb_iso3166_code *iso3166;
+ struct rxkb_iso639_code *iso639;
ctx = test_setup_context(system_models, NULL,
system_layouts, NULL,
assert(cmp_layouts(&system_layouts[1], l));
rxkb_layout_unref(l);
+ l = fetch_layout(ctx, "l2", "v2");
+ iso3166 = rxkb_layout_get_iso3166_first(l);
+ assert(streq(rxkb_iso3166_code_get_code(iso3166), "op"));
+ iso3166 = rxkb_iso3166_code_next(iso3166);
+ assert(streq(rxkb_iso3166_code_get_code(iso3166), "qr"));
+
+ iso639 = rxkb_layout_get_iso639_first(l);
+ assert(streq(rxkb_iso639_code_get_code(iso639), "hij"));
+ iso639 = rxkb_iso639_code_next(iso639);
+ assert(streq(rxkb_iso639_code_get_code(iso639), "klm"));
+
+ rxkb_layout_unref(l);
rxkb_context_unref(ctx);
}