summaryrefslogtreecommitdiff
path: root/tests/test_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_config.c')
-rw-r--r--tests/test_config.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/tests/test_config.c b/tests/test_config.c
index df8974b..1defebb 100644
--- a/tests/test_config.c
+++ b/tests/test_config.c
@@ -42,7 +42,8 @@ main(int argc, char *const argv[])
int binary = 0;
Display *dpy;
- g_type_init_with_debug_flags(G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS);
+ g_type_init_with_debug_flags(G_TYPE_DEBUG_OBJECTS |
+ G_TYPE_DEBUG_SIGNALS);
while (1) {
c = getopt(argc, argv, "hsgm:l:o:d:w:");
@@ -94,23 +95,24 @@ main(int argc, char *const argv[])
exit(1);
}
printf("opened display: %p\n", dpy);
- XklEngine * engine = xkl_engine_get_instance(dpy);
- if (engine == NULL) {
+ XklEngine *engine = xkl_engine_get_instance(dpy);
+ if (engine != NULL) {
XklConfigRec *current_config, *r2;
if (debug_level != -1)
xkl_set_debug_level(debug_level);
xkl_debug(0, "Xklavier initialized\n");
- XklConfig * config = xkl_config_get_instance(engine);
+ XklConfig *config = xkl_config_get_instance(engine);
xkl_config_load_registry(config);
xkl_debug(0, "Xklavier registry loaded\n");
- xkl_debug(0, "Backend: [%s]\n", xkl_engine_get_backend_name(engine));
+ xkl_debug(0, "Backend: [%s]\n",
+ xkl_engine_get_backend_name(engine));
xkl_debug(0, "Supported features: 0x0%X\n",
xkl_engine_get_features(engine));
xkl_debug(0, "Max number of groups: %d\n",
xkl_engine_get_max_num_groups(engine));
current_config = xkl_config_rec_new();
- xkl_config_rec_get_from_server(current_config,engine);
+ xkl_config_rec_get_from_server(current_config, engine);
switch (action) {
case ACTION_GET:
@@ -119,27 +121,30 @@ main(int argc, char *const argv[])
r2 = xkl_config_rec_new();
- if (xkl_config_rec_get_from_backup(r2,engine)) {
+ if (xkl_config_rec_get_from_backup(r2, engine)) {
xkl_debug(0,
"Got config from the backup\n");
xkl_config_dump(stdout, r2);
}
- if (xkl_config_rec_activate(r2,engine)) {
+ if (xkl_config_rec_activate(r2, engine)) {
xkl_debug(0,
"The backup configuration restored\n");
- if (xkl_config_rec_activate(current_config,engine)) {
+ if (xkl_config_rec_activate
+ (current_config, engine)) {
xkl_debug(0,
"Reverting the configuration change\n");
} else {
xkl_debug(0,
"The configuration could not be reverted: %s\n",
- xkl_engine_get_last_error(engine));
+ xkl_engine_get_last_error
+ (engine));
}
} else {
xkl_debug(0,
"The backup configuration could not be restored: %s\n",
- xkl_engine_get_last_error(engine));
+ xkl_engine_get_last_error
+ (engine));
}
g_object_unref(G_OBJECT(r2));
@@ -153,12 +158,14 @@ main(int argc, char *const argv[])
if (layouts != NULL) {
if (current_config->layouts != NULL)
- g_strfreev(current_config->layouts);
+ g_strfreev(current_config->
+ layouts);
if (current_config->variants != NULL)
g_strfreev(current_config->
variants);
- current_config->layouts = g_new0(char *, 2);
+ current_config->layouts =
+ g_new0(char *, 2);
current_config->layouts[0] =
g_strdup(layouts);
current_config->variants =
@@ -168,26 +175,33 @@ main(int argc, char *const argv[])
if (options != NULL) {
if (current_config->options != NULL)
- g_strfreev(current_config->options);
+ g_strfreev(current_config->
+ options);
- current_config->options = g_new0(char *, 2);
+ current_config->options =
+ g_new0(char *, 2);
current_config->options[0] =
g_strdup(options);
}
xkl_debug(0, "New config:\n");
xkl_config_dump(stdout, current_config);
- if (xkl_config_rec_activate(current_config,engine))
+ if (xkl_config_rec_activate
+ (current_config, engine))
xkl_debug(0, "Set the config\n");
else
xkl_debug(0,
"Could not set the config: %s\n",
- xkl_engine_get_last_error(engine));
+ xkl_engine_get_last_error
+ (engine));
break;
case ACTION_WRITE:
- xkl_config_rec_write_to_file(engine,binary ? (PACKAGE ".xkm")
- : (PACKAGE ".xkb"),
- current_config, binary);
+ xkl_config_rec_write_to_file(engine,
+ binary ? (PACKAGE
+ ".xkm")
+ : (PACKAGE ".xkb"),
+ current_config,
+ binary);
xkl_debug(0, "The file " PACKAGE "%s is written\n",
binary ? ".xkm" : ".xkb");
break;