~aleteoryx/muditaos

ref: 6ced1ee3e865adee03e8ae1ffaa80dcd15e32cf4 muditaos/module-utils/Clipboard/test/unittest_clipboard.cpp -rw-r--r-- 1.6 KiB
6ced1ee3 — Mateusz Piesta [BH-1495] Relaxation app assets update 3 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
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <catch2/catch.hpp>
#include <Clipboard.hpp>

TEST_CASE("Clipboard")
{
    SECTION("No data")
    {
        // It is guaranted to have no data only during 1st call to singleton getInstance()
        REQUIRE(Clipboard::getInstance().gotData() == false);
        REQUIRE(Clipboard::getInstance().paste() == "");
    }

    SECTION("Single copy")
    {
        const std::string test1 = "test1";
        const std::string test2 = "test2";
        Clipboard::getInstance().copy(test1);
        REQUIRE(Clipboard::getInstance().gotData() == true);
        REQUIRE(Clipboard::getInstance().paste() == test1);
        REQUIRE(Clipboard::getInstance().gotData() == true);
    }

    SECTION("Double copy")
    {
        const std::string test1 = "test1";
        const std::string test2 = "test2";
        Clipboard::getInstance().copy(test1);
        REQUIRE(Clipboard::getInstance().gotData() == true);
        Clipboard::getInstance().copy(test2);
        REQUIRE(Clipboard::getInstance().gotData() == true);
        REQUIRE(Clipboard::getInstance().paste() == test2);
        REQUIRE(Clipboard::getInstance().gotData() == true);
    }

    SECTION("Copy empty string")
    {
        const std::string test1 = "";
        Clipboard::getInstance().copy(test1);
        REQUIRE(Clipboard::getInstance().gotData() == true);
        REQUIRE(Clipboard::getInstance().paste() == test1);
        REQUIRE(Clipboard::getInstance().gotData() == true);
    }
}