~aleteoryx/muditaos

ref: d4d0e7ec3487e64649f764c2bbcf5c25cf3c204d muditaos/module-gui/test/test-catch/test-gui-image.cpp -rw-r--r-- 1.4 KiB
d4d0e7ec — Tomasz Rybarski [BH-1222] Alarm Bottom Message Translations 4 years 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
54
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <catch2/catch.hpp>
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file

#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());
}