mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Add tests for sf::Clipboard
This commit is contained in:
parent
1811951b4a
commit
d304d1e57b
@ -59,6 +59,7 @@ target_compile_definitions(test-sfml-system PRIVATE
|
||||
)
|
||||
|
||||
set(WINDOW_SRC
|
||||
Window/Clipboard.test.cpp
|
||||
Window/Context.test.cpp
|
||||
Window/ContextSettings.test.cpp
|
||||
Window/Cursor.test.cpp
|
||||
|
28
test/Window/Clipboard.test.cpp
Normal file
28
test/Window/Clipboard.test.cpp
Normal file
@ -0,0 +1,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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user