~ test reset
This commit is contained in:
parent
300cf1ac28
commit
5e97100181
@ -40,3 +40,12 @@ target_link_libraries(UnitTests Catch2::Catch2)
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
catch_discover_tests(UnitTests)
|
||||
|
||||
if (ENABLE_COVERAGE)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../external/codecov/cmake" ${CMAKE_MODULE_PATH})
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
|
||||
find_package(codecov)
|
||||
add_coverage(UnitTests)
|
||||
list(APPEND LCOV_REMOVE_PATTERNS "/usr/")
|
||||
coverage_evaluate()
|
||||
endif()
|
||||
|
@ -8,6 +8,24 @@ namespace vkvm {
|
||||
|
||||
Impl impl;
|
||||
|
||||
auto setDefaultValues() -> void {
|
||||
impl.localMemoryWarn = false;
|
||||
if (getSharedMemory() != nullptr) {
|
||||
setMode(GraphicMode::RGB);
|
||||
setCharactersPerRow(60);
|
||||
setCharactersPerColumn(20);
|
||||
setHeight(600);
|
||||
setWidth(800);
|
||||
setMousePosition(42, 42);
|
||||
setBackgroundColor(black);
|
||||
setForegroundColor(white);
|
||||
setRedrawInterval(20);
|
||||
setTimerInterruptInterval(10);
|
||||
setFont(FontType(3, "", 0, 0));
|
||||
}
|
||||
impl.localMemoryWarn = true;
|
||||
}
|
||||
|
||||
auto sendSignal(pid_t pid, int signalNumber) -> void {
|
||||
kill(pid, signalNumber);
|
||||
}
|
||||
|
@ -65,6 +65,9 @@ constexpr int keyboardBufferSize = 16;
|
||||
|
||||
extern Impl impl;
|
||||
|
||||
|
||||
auto setDefaultValues() -> void;
|
||||
|
||||
/**
|
||||
* send a signal to a process
|
||||
* @param pid of the process to which the signal is send
|
||||
|
20
src/vkvm.cpp
20
src/vkvm.cpp
@ -15,24 +15,6 @@ namespace vkvm {
|
||||
setDefaultValues();
|
||||
}
|
||||
|
||||
auto setDefaultValues() -> void {
|
||||
impl.localMemoryWarn = false;
|
||||
if (getSharedMemory() != nullptr) {
|
||||
setMode(GraphicMode::RGB);
|
||||
setCharactersPerRow(60);
|
||||
setCharactersPerColumn(20);
|
||||
setHeight(600);
|
||||
setWidth(800);
|
||||
setMousePosition(42, 42);
|
||||
setBackgroundColor(black);
|
||||
setForegroundColor(white);
|
||||
setRedrawInterval(20);
|
||||
setTimerInterruptInterval(10);
|
||||
setFont(FontType(3, "", 0, 0));
|
||||
}
|
||||
impl.localMemoryWarn = true;
|
||||
}
|
||||
|
||||
auto registerEvent(EventType type, const std::function<void()> &handler) -> bool {
|
||||
int signum = SIGUSR1 + impl.eventTable.size();
|
||||
auto ivt = getInterruptTable();
|
||||
@ -205,7 +187,7 @@ namespace vkvm {
|
||||
}
|
||||
|
||||
auto reset() -> void {
|
||||
//TODO(julian): reset
|
||||
setDefaultValues();
|
||||
}
|
||||
|
||||
auto getWidth() -> int {
|
||||
|
@ -28,7 +28,6 @@ namespace vkvm {
|
||||
*/
|
||||
auto initialize(int pid) -> void;
|
||||
|
||||
auto setDefaultValues() -> void;
|
||||
|
||||
/**
|
||||
* set pixel at a x,y position to a certain color.
|
||||
|
70
test/default_test.cpp
Normal file
70
test/default_test.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#include "../src/internal.hpp"
|
||||
#include "../src/vkvm.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
TEST_CASE("Default values") {
|
||||
vkvm::initialize(0);
|
||||
|
||||
SECTION("before") {
|
||||
REQUIRE(vkvm::getMode() == vkvm::RGB);
|
||||
REQUIRE(vkvm::getCharactersPerRow() == 60);
|
||||
REQUIRE(vkvm::getCharactersPerColumn() == 20);
|
||||
REQUIRE(vkvm::getHeight() == 600);
|
||||
REQUIRE(vkvm::getWidth() == 800);
|
||||
REQUIRE(vkvm::getMousePosition().x == 42);
|
||||
REQUIRE(vkvm::getMousePosition().y == 42);
|
||||
REQUIRE(vkvm::getBackgroundColor() == vkvm::black);
|
||||
REQUIRE(vkvm::getForegroundColor() == vkvm::white);
|
||||
REQUIRE(vkvm::getRedrawInterval() == 20);
|
||||
REQUIRE(vkvm::getTimerInterruptInterval() == 10);
|
||||
REQUIRE(vkvm::getFont().getId() == 3);
|
||||
}
|
||||
|
||||
SECTION("change") {
|
||||
vkvm::setMode(vkvm::TwoColors);
|
||||
vkvm::setCharactersPerRow(100);
|
||||
vkvm::setCharactersPerColumn(100);
|
||||
vkvm::setHeight(40);
|
||||
vkvm::setWidth(40);
|
||||
vkvm::setMousePosition(41, 43);
|
||||
vkvm::setBackgroundColor(vkvm::red);
|
||||
vkvm::setForegroundColor(vkvm::blue);
|
||||
vkvm::setRedrawInterval(1);
|
||||
vkvm::setTimerInterruptInterval(2);
|
||||
vkvm::setFont(vkvm::FontType(5, "", 5, 5));
|
||||
|
||||
|
||||
|
||||
REQUIRE(vkvm::getMode() == vkvm::TwoColors);
|
||||
REQUIRE(vkvm::getCharactersPerRow() == 100);
|
||||
REQUIRE(vkvm::getCharactersPerColumn() == 100);
|
||||
REQUIRE(vkvm::getHeight() == 40);
|
||||
REQUIRE(vkvm::getWidth() == 40);
|
||||
REQUIRE(vkvm::getMousePosition().x == 41);
|
||||
REQUIRE(vkvm::getMousePosition().y == 43);
|
||||
REQUIRE(vkvm::getBackgroundColor() == vkvm::red);
|
||||
REQUIRE(vkvm::getForegroundColor() == vkvm::blue);
|
||||
REQUIRE(vkvm::getRedrawInterval() == 1);
|
||||
REQUIRE(vkvm::getTimerInterruptInterval() == 2);
|
||||
REQUIRE(vkvm::getFont().getId() == 5);
|
||||
}
|
||||
|
||||
|
||||
SECTION("after") {
|
||||
vkvm::reset();
|
||||
REQUIRE(vkvm::getMode() == vkvm::RGB);
|
||||
REQUIRE(vkvm::getCharactersPerRow() == 60);
|
||||
REQUIRE(vkvm::getCharactersPerColumn() == 20);
|
||||
REQUIRE(vkvm::getHeight() == 600);
|
||||
REQUIRE(vkvm::getWidth() == 800);
|
||||
REQUIRE(vkvm::getMousePosition().x == 42);
|
||||
REQUIRE(vkvm::getMousePosition().y == 42);
|
||||
REQUIRE(vkvm::getBackgroundColor() == vkvm::black);
|
||||
REQUIRE(vkvm::getForegroundColor() == vkvm::white);
|
||||
REQUIRE(vkvm::getRedrawInterval() == 20);
|
||||
REQUIRE(vkvm::getTimerInterruptInterval() == 10);
|
||||
REQUIRE(vkvm::getFont().getId() == 3);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user