diff --git a/CMakeLists.txt b/CMakeLists.txt index 39e3243..cc1ea7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,9 @@ add_custom_command(TARGET lvt_wpf_tap POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/tap_wpf/bin/Release/LvtWpfTap.dll" "$/LvtWpfTap.dll" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_SOURCE_DIR}/src/tap_wpf/LvtWpfTap.runtimeconfig.json" + "$/LvtWpfTap.runtimeconfig.json" COMMENT "Copying managed WPF tree walker assembly" ) @@ -288,19 +291,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/src/tap_wpf/LvtWpfTap.runtimeconfig.json b/src/tap_wpf/LvtWpfTap.runtimeconfig.json new file mode 100644 index 0000000..b723c2a --- /dev/null +++ b/src/tap_wpf/LvtWpfTap.runtimeconfig.json @@ -0,0 +1,9 @@ +{ + "runtimeOptions": { + "framework": { + "name": "Microsoft.WindowsDesktop.App", + "version": "8.0.0", + "rollForward": "LatestMajor" + } + } +} diff --git a/src/tap_wpf/wpf_tap_native.cpp b/src/tap_wpf/wpf_tap_native.cpp index 7d5b2a4..3f5d3b2 100644 --- a/src/tap_wpf/wpf_tap_native.cpp +++ b/src/tap_wpf/wpf_tap_native.cpp @@ -247,7 +247,8 @@ static bool TryNetCore(const std::wstring& assemblyPath, const std::wstring& pip fprintf(f, "{\n \"runtimeOptions\": {\n" " \"framework\": {\n" " \"name\": \"Microsoft.WindowsDesktop.App\",\n" - " \"version\": \"8.0.0\"\n" + " \"version\": \"8.0.0\",\n" + " \"rollForward\": \"LatestMajor\"\n" " }\n }\n}\n"); fclose(f); LogMsg("Created runtimeconfig.json"); 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 @@ + + + + + + + + + + + + + + + + + + +