From a7a7753fe6227daad2a99208e686770e690ef282 Mon Sep 17 00:00:00 2001 From: Alexander Sklar <22989529+asklar@users.noreply.github.com> Date: Wed, 8 Jul 2026 20:47:52 -0700 Subject: [PATCH 1/2] Add WPF sample durable-key integration test Part of #30. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 18 ++- tests/apps/WpfSample/App.xaml | 6 + tests/apps/WpfSample/App.xaml.cs | 7 ++ tests/apps/WpfSample/MainWindow.xaml | 28 +++++ tests/apps/WpfSample/MainWindow.xaml.cs | 11 ++ tests/apps/WpfSample/WpfSample.csproj | 10 ++ tests/integration_tests.cpp | 157 ++++++++++++++++++++++++ 7 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 tests/apps/WpfSample/App.xaml create mode 100644 tests/apps/WpfSample/App.xaml.cs create mode 100644 tests/apps/WpfSample/MainWindow.xaml create mode 100644 tests/apps/WpfSample/MainWindow.xaml.cs create mode 100644 tests/apps/WpfSample/WpfSample.csproj diff --git a/CMakeLists.txt b/CMakeLists.txt index 39e3243..6fe840c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,19 +288,35 @@ target_link_libraries(lvt_unit_tests PRIVATE ) add_test(NAME unit_tests COMMAND lvt_unit_tests) +# WPF sample app used by integration tests +set(WPF_SAMPLE_PROJECT "${CMAKE_SOURCE_DIR}/tests/apps/WpfSample/WpfSample.csproj") +set(WPF_SAMPLE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/tests/apps/WpfSample") +add_custom_target(wpf_sample_app ALL + COMMAND dotnet build "${WPF_SAMPLE_PROJECT}" -c Release -o "${WPF_SAMPLE_OUTPUT_DIR}" + BYPRODUCTS "${WPF_SAMPLE_OUTPUT_DIR}/WpfSample.exe" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Building WPF sample app" +) +file(TO_NATIVE_PATH "${WPF_SAMPLE_OUTPUT_DIR}/WpfSample.exe" WPF_SAMPLE_EXE_NATIVE) +string(REPLACE "\\" "\\\\" WPF_SAMPLE_EXE_ESCAPED "${WPF_SAMPLE_EXE_NATIVE}") + # Integration tests — require a running Notepad instance add_executable(lvt_integration_tests tests/integration_tests.cpp tests/lvt_integration_tests.rc ) target_include_directories(lvt_integration_tests PRIVATE src) -target_compile_definitions(lvt_integration_tests PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX WINRT_LEAN_AND_MEAN UNICODE _UNICODE) +target_compile_definitions(lvt_integration_tests PRIVATE + WIN32_LEAN_AND_MEAN NOMINMAX WINRT_LEAN_AND_MEAN UNICODE _UNICODE + WPF_SAMPLE_EXE_PATH="${WPF_SAMPLE_EXE_ESCAPED}" +) target_link_libraries(lvt_integration_tests PRIVATE GTest::gtest GTest::gtest_main WIL::WIL nlohmann_json::nlohmann_json comctl32 ) target_link_options(lvt_integration_tests PRIVATE "/MANIFEST:NO") +add_dependencies(lvt_integration_tests wpf_sample_app) add_test(NAME integration_tests COMMAND lvt_integration_tests) # Chromium plugin tests — DOM JSON format and native messaging protocol diff --git a/tests/apps/WpfSample/App.xaml b/tests/apps/WpfSample/App.xaml new file mode 100644 index 0000000..ae68159 --- /dev/null +++ b/tests/apps/WpfSample/App.xaml @@ -0,0 +1,6 @@ + + + diff --git a/tests/apps/WpfSample/App.xaml.cs b/tests/apps/WpfSample/App.xaml.cs new file mode 100644 index 0000000..9b587c7 --- /dev/null +++ b/tests/apps/WpfSample/App.xaml.cs @@ -0,0 +1,7 @@ +using System.Windows; + +namespace WpfSample; + +public partial class App : Application +{ +} diff --git a/tests/apps/WpfSample/MainWindow.xaml b/tests/apps/WpfSample/MainWindow.xaml new file mode 100644 index 0000000..7ee56c5 --- /dev/null +++ b/tests/apps/WpfSample/MainWindow.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + +