File: Clipboard.test.cpp

package info (click to toggle)
libsfml 3.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 13,704 kB
  • sloc: cpp: 52,754; ansic: 24,944; objc: 668; sh: 172; xml: 25; makefile: 18
file content (28 lines) | stat: -rw-r--r-- 853 bytes parent folder | download
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
#include <SFML/Window/Clipboard.hpp>

// Other 1st party headers
#include <SFML/System/String.hpp>

#include <catch2/catch_test_macros.hpp>

#include <WindowUtil.hpp>

TEST_CASE("[Window] sf::Clipboard", runDisplayTests())
{
    // Capture current clipboard state
    const auto currentClipboard = sf::Clipboard::getString();

    SECTION("Set/get string")
    {
        sf::Clipboard::setString("Welcome to SFML!");
        CHECK(sf::Clipboard::getString() == "Welcome to SFML!");
    }

    // Restore clipboard
    sf::Clipboard::setString(currentClipboard);

    // We rely on getString triggering clipboard event processing on X11 to make
    // setString work, but note that the way setString is guaranteed to work is
    // by having an open window for which events are being handled.
    CHECK(sf::Clipboard::getString() == currentClipboard);
}