~aleteoryx/muditaos

muditaos/module-gui/test/test-catch/test-gui-image.cpp -rw-r--r-- 1.3 KiB
a405cad6Aleteoryx trim readme 6 days ago
                                                                                
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
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#include <catch2/catch.hpp>

#include <list>

#include <module-gui/gui/core/DrawCommand.hpp>
#include <module-gui/gui/core/ImageManager.hpp>
#include <module-gui/gui/widgets/Image.hpp>

TEST_CASE("Constructing with empty image name")
{
    constexpr auto imageName = "";
    gui::Image image{nullptr, imageName};

    std::list<gui::Command> commands;
    image.buildDrawListImplementation(commands);
    REQUIRE(commands.empty());
}

TEST_CASE("Setting an empty image name")
{
    constexpr auto imageName = "";
    gui::Image image{};
    image.set(imageName);

    std::list<gui::Command> commands;
    image.buildDrawListImplementation(commands);
    REQUIRE(commands.empty());
}

TEST_CASE("Setting an incorrect image name")
{
    constexpr auto imageName = "ABC";
    gui::Image image{};
    image.set(imageName);

    std::list<gui::Command> commands;
    image.buildDrawListImplementation(commands);
    REQUIRE(!commands.empty());
}

TEST_CASE("Setting an incorrect image id")
{
    constexpr auto imageId = 1000;
    gui::Image image{};
    image.set(imageId);

    std::list<gui::Command> commands;
    image.buildDrawListImplementation(commands);
    REQUIRE(!commands.empty());
}