aboutsummaryrefslogtreecommitdiff
path: root/tests/tst_utils.vala
blob: a7a624bea0543c6c704ad9e043b10c6125d6dfe5 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using AyatanaCommon;
using Environment;
using GLib;

static int main(string[] args)
{
    assert(args.length == 2);
    unset_variable("DESKTOP_SESSION");

    unset_variable("XDG_CURRENT_DESKTOP");
    assert(! utils_is_lomiri());
    set_variable("XDG_CURRENT_DESKTOP", "Lomiri", true);
    assert(utils_is_lomiri());

    unset_variable("XDG_CURRENT_DESKTOP");
    assert(! utils_is_gnome());
    set_variable("XDG_CURRENT_DESKTOP", "GNOME", true);
    assert(utils_is_gnome());

    unset_variable("XDG_CURRENT_DESKTOP");
    assert(! utils_is_unity());
    set_variable("XDG_CURRENT_DESKTOP", "Unity", true);
    assert(utils_is_unity());

    unset_variable("XDG_CURRENT_DESKTOP");
    assert(! utils_is_mate());
    set_variable("XDG_CURRENT_DESKTOP", "MATE", true);
    assert(utils_is_mate());

    unset_variable("XDG_CURRENT_DESKTOP");
    assert(! utils_is_xfce());
    set_variable("XDG_CURRENT_DESKTOP", "XFCE", true);
    assert(utils_is_xfce());

    unset_variable("XDG_CURRENT_DESKTOP");
    assert(! utils_is_pantheon());
    set_variable("XDG_CURRENT_DESKTOP", "PANTHEON", true);
    assert(utils_is_pantheon());

    unset_variable("XDG_CURRENT_DESKTOP");
    assert(! utils_is_budgie());
    set_variable("XDG_CURRENT_DESKTOP", "Budgie:GNOME", true);
    assert(utils_is_budgie());

    unset_variable("XDG_CURRENT_DESKTOP");
    set_variable("GSETTINGS_SCHEMA_DIR", args[1], true);
    set_variable("GSETTINGS_BACKEND", "memory", true);

    Settings pSettings = new Settings("org.ayatana.common");
    string sTest = "123456789012345678901234567890123456789012345öüóőúéáűšđß";
    pSettings.set_uint("max-menu-text-length", 0);
    utils_ellipsize(sTest);
    assert(sTest == "123456789012345678901234567890123456789012345öüóőúéáűšđß");

    pSettings.set_uint("max-menu-text-length", 100);
    utils_ellipsize(sTest);
    assert(sTest == "123456789012345678901234567890123456789012345öüóőúéáűšđß");

    pSettings.set_uint("max-menu-text-length", 50);
    utils_ellipsize(sTest);
    assert(sTest == "123456789012345678901234567890123456789012345öüóőú...");

    return 0;
}