bemenu/test/bm_menu_new.c
Jari Vetoniemi 074b2d1b58 Remove --backend and --prioritory options, change prioritory -> priorty
and provide BEMENU_BACKEND env variable. Change API to reflect this
change.

There is no reliable way to detect when running on terminal (especially
when stdin is a pipe), so we need to make curses backend explicit with
BEMENU_BACKEND=curses or bm_menu_new("curses"), otherwise GUI backend
will be choosed automatically.
2015-01-17 18:53:29 +02:00

42 lines
1.1 KiB
C

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <bemenu.h>
int
main(int argc, char **argv)
{
(void)argc, (void)argv;
unsetenv("BEMENU_RENDERER");
setenv("BEMENU_RENDERERS", "../renderers", true);
if (!bm_init())
return EXIT_FAILURE;
// TEST: Instance bmMenu with all possible draw modes.
{
uint32_t count;
const struct bm_renderer **renderers = bm_get_renderers(&count);
for (int32_t i = 0; i < count; ++i) {
struct bm_menu *menu = bm_menu_new(bm_renderer_get_name(renderers[i]));
if (!strcmp(bm_renderer_get_name(renderers[i]), "curses") && !isatty(STDIN_FILENO)) {
// do not test
continue;
} else if (!strcmp(bm_renderer_get_name(renderers[i]), "wayland") && !getenv("WAYLAND_DISPLAY")) {
// do not test
continue;
}
assert(menu);
bm_menu_render(menu);
bm_menu_free(menu);
}
}
return EXIT_SUCCESS;
}
/* vim: set ts=8 sw=4 tw=0 :*/