Milestone 5: deliver embedded RDP sessions and lifecycle hardening
This commit is contained in:
39
third_party/FreeRDP/client/SDL/common/test/CMakeLists.txt
vendored
Normal file
39
third_party/FreeRDP/client/SDL/common/test/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
set(MODULE_NAME "TestSDL2")
|
||||
set(MODULE_PREFIX "TEST_SDL")
|
||||
|
||||
set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.cpp)
|
||||
|
||||
set(${MODULE_PREFIX}_TESTS TestSDLPrefs.cpp TestSDLWebview.cpp)
|
||||
|
||||
disable_warnings_for_directory(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
create_test_sourcelist(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_DRIVER} ${${MODULE_PREFIX}_TESTS})
|
||||
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../aad")
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../aad")
|
||||
|
||||
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||
|
||||
set(${MODULE_PREFIX}_LIBS freerdp freerdp-client winpr sdl-common-prefs sdl-common-aad-view)
|
||||
|
||||
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}")
|
||||
|
||||
set(TEST_SRC_AREA "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(TEST_BIN_AREA "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
if(WIN32)
|
||||
string(REPLACE "\\" "\\\\" TEST_SRC_AREA "${TEST_SRC_AREA}")
|
||||
string(REPLACE "\\" "\\\\" TEST_BIN_AREA "${TEST_BIN_AREA}")
|
||||
endif()
|
||||
|
||||
add_compile_definitions(TEST_SRC_AREA="${TEST_SRC_AREA}")
|
||||
add_compile_definitions(TEST_BIN_AREA="${TEST_BIN_AREA}")
|
||||
|
||||
foreach(test ${${MODULE_PREFIX}_TESTS})
|
||||
get_filename_component(TestName ${test} NAME_WE)
|
||||
add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName})
|
||||
endforeach()
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/Client/Test")
|
||||
121
third_party/FreeRDP/client/SDL/common/test/TestSDLPrefs.cpp
vendored
Normal file
121
third_party/FreeRDP/client/SDL/common/test/TestSDLPrefs.cpp
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
#include "../sdl_prefs.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <winpr/config.h>
|
||||
#include <winpr/winpr.h>
|
||||
|
||||
#if __has_include(<filesystem>)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#error Could not find system header "<filesystem>" or "<experimental/filesystem>"
|
||||
#endif
|
||||
|
||||
static std::shared_ptr<SdlPref> instance()
|
||||
{
|
||||
#if !defined(TEST_SRC_AREA)
|
||||
#error "Please define TEST_SRC_AREA to the source directory of this test case"
|
||||
#endif
|
||||
fs::path src(TEST_SRC_AREA);
|
||||
src /= "sdl-freerdp.json";
|
||||
if (!fs::exists(src))
|
||||
{
|
||||
std::cerr << "[ERROR] test configuration file '" << src << "' does not exist" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return SdlPref::instance(src.string());
|
||||
}
|
||||
|
||||
int TestSDLPrefs(int argc, char* argv[])
|
||||
{
|
||||
WINPR_UNUSED(argc);
|
||||
WINPR_UNUSED(argv);
|
||||
|
||||
#if defined(WITH_WINPR_JSON)
|
||||
printf("implementation: json\n");
|
||||
#else
|
||||
printf("implementation: fallback\n");
|
||||
#endif
|
||||
|
||||
#if defined(WITH_WINPR_JSON)
|
||||
printf("config: %s\n", instance()->get_pref_file().c_str());
|
||||
#endif
|
||||
|
||||
auto string_value = instance()->get_string("string_key", "cba");
|
||||
#if defined(WITH_WINPR_JSON)
|
||||
if (string_value != "abc")
|
||||
return -1;
|
||||
#else
|
||||
if (string_value != "cba")
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
auto string_value_nonexistent = instance()->get_string("string_key_nonexistent", "cba");
|
||||
if (string_value_nonexistent != "cba")
|
||||
return -1;
|
||||
|
||||
auto int_value = instance()->get_int("int_key", 321);
|
||||
#if defined(WITH_WINPR_JSON)
|
||||
if (int_value != 123)
|
||||
return -1;
|
||||
#else
|
||||
if (int_value != 321)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
auto int_value_nonexistent = instance()->get_int("int_key_nonexistent", 321);
|
||||
if (int_value_nonexistent != 321)
|
||||
return -1;
|
||||
|
||||
auto bool_value = instance()->get_bool("bool_key", false);
|
||||
#if defined(WITH_WINPR_JSON)
|
||||
if (!bool_value)
|
||||
return -1;
|
||||
#else
|
||||
if (bool_value)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
auto bool_value_nonexistent = instance()->get_bool("bool_key_nonexistent", false);
|
||||
if (bool_value_nonexistent)
|
||||
return -1;
|
||||
|
||||
auto array_value = instance()->get_array("array_key", { "c", "b", "a" });
|
||||
if (array_value.size() != 3)
|
||||
return -1;
|
||||
#if defined(WITH_WINPR_JSON)
|
||||
if (array_value.at(0) != "a")
|
||||
return -1;
|
||||
if (array_value.at(1) != "b")
|
||||
return -1;
|
||||
if (array_value.at(2) != "c")
|
||||
return -1;
|
||||
#else
|
||||
if (array_value.at(0) != "c")
|
||||
return -1;
|
||||
if (array_value.at(1) != "b")
|
||||
return -1;
|
||||
if (array_value.at(2) != "a")
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
auto array_value_nonexistent =
|
||||
instance()->get_array("array_key_nonexistent", { "c", "b", "a" });
|
||||
if (array_value_nonexistent.size() != 3)
|
||||
return -1;
|
||||
|
||||
if (array_value_nonexistent.at(0) != "c")
|
||||
return -1;
|
||||
if (array_value_nonexistent.at(1) != "b")
|
||||
return -1;
|
||||
if (array_value_nonexistent.at(2) != "a")
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
30
third_party/FreeRDP/client/SDL/common/test/TestSDLWebview.cpp
vendored
Normal file
30
third_party/FreeRDP/client/SDL/common/test/TestSDLWebview.cpp
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
#include <winpr/config.h>
|
||||
#include <winpr/winpr.h>
|
||||
|
||||
#include <sdl_webview.hpp>
|
||||
|
||||
int TestSDLWebview(WINPR_ATTR_UNUSED int argc, WINPR_ATTR_UNUSED char* argv[])
|
||||
{
|
||||
#if 0
|
||||
RDP_CLIENT_ENTRY_POINTS entry = {};
|
||||
entry.Version = RDP_CLIENT_INTERFACE_VERSION;
|
||||
entry.Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
|
||||
entry.ContextSize = sizeof(rdpContext);
|
||||
|
||||
std::shared_ptr<rdpContext> context(freerdp_client_context_new(&entry),
|
||||
[](rdpContext* ptr) { freerdp_client_context_free(ptr); });
|
||||
|
||||
char* token = nullptr;
|
||||
if (!sdl_webview_get_access_token(context->instance, ACCESS_TOKEN_TYPE_AAD, &token, 2, "scope",
|
||||
"foobar"))
|
||||
{
|
||||
std::cerr << "test failed!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
10
third_party/FreeRDP/client/SDL/common/test/sdl-freerdp.json
vendored
Normal file
10
third_party/FreeRDP/client/SDL/common/test/sdl-freerdp.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"string_key": "abc",
|
||||
"int_key": 123,
|
||||
"bool_key": true,
|
||||
"array_key": [
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user