summaryrefslogtreecommitdiff
path: root/test/bm_menu_new.c
blob: 20ecbd5a248d5ae947c19883362534b86405f0b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#define _DEFAULT_SOURCE
#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)) {
                assert(!menu);
                continue;
            } else if (!strcmp(bm_renderer_get_name(renderers[i]), "wayland") && !getenv("WAYLAND_DISPLAY")) {
                assert(!menu);
                continue;
            }
            assert(menu);
            bm_menu_render(menu);
            bm_menu_free(menu);
        }
    }

    return EXIT_SUCCESS;
}

/* vim: set ts=8 sw=4 tw=0 :*/