From 4c91eda7a1a0cea9e115943470c31ba328f50041 Mon Sep 17 00:00:00 2001 From: Alexander Sklar <22989529+asklar@users.noreply.github.com> Date: Wed, 8 Jul 2026 20:58:43 -0700 Subject: [PATCH 1/2] Add WinUI3 durable-key integration test Add an unpackaged self-contained WinUI3 sample app and publish it for integration tests. Verify WinUI3 durable keys are present, unique, deterministic across dumps, queryable by key, and grafted under DesktopChildSiteBridge. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .gitignore | 2 + CMakeLists.txt | 29 +++- tests/apps/WinUI3Sample/App.xaml | 5 + tests/apps/WinUI3Sample/App.xaml.cs | 19 +++ tests/apps/WinUI3Sample/MainWindow.xaml | 20 +++ tests/apps/WinUI3Sample/MainWindow.xaml.cs | 12 ++ tests/apps/WinUI3Sample/WinUI3Sample.csproj | 25 +++ tests/integration_tests.cpp | 164 ++++++++++++++++++++ 8 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 tests/apps/WinUI3Sample/App.xaml create mode 100644 tests/apps/WinUI3Sample/App.xaml.cs create mode 100644 tests/apps/WinUI3Sample/MainWindow.xaml create mode 100644 tests/apps/WinUI3Sample/MainWindow.xaml.cs create mode 100644 tests/apps/WinUI3Sample/WinUI3Sample.csproj diff --git a/.gitignore b/.gitignore index 9960f95..036b9c9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ build/ build-x86/ build-arm64/ +tests/apps/WinUI3Sample/bin/ +tests/apps/WinUI3Sample/obj/ # IDE files .vs/ diff --git a/CMakeLists.txt b/CMakeLists.txt index cc1ea7f..049db12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -303,6 +303,32 @@ add_custom_target(wpf_sample_app ALL file(TO_NATIVE_PATH "${WPF_SAMPLE_OUTPUT_DIR}/WpfSample.exe" WPF_SAMPLE_EXE_NATIVE) string(REPLACE "\\" "\\\\" WPF_SAMPLE_EXE_ESCAPED "${WPF_SAMPLE_EXE_NATIVE}") +# WinUI3 sample app used by integration tests +set(WINUI3_SAMPLE_PROJECT "${CMAKE_SOURCE_DIR}/tests/apps/WinUI3Sample/WinUI3Sample.csproj") +set(WINUI3_SAMPLE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/tests/apps/WinUI3Sample") +set(WINUI3_SAMPLE_MSBUILD_ARGS "") +if(DEFINED ENV{VSINSTALLDIR} AND EXISTS "$ENV{VSINSTALLDIR}/MSBuild/Microsoft/VisualStudio/v18.0/AppxPackage/Microsoft.Build.Packaging.Pri.Tasks.dll") + list(APPEND WINUI3_SAMPLE_MSBUILD_ARGS + "-p:MSBuildExtensionsPath=$ENV{VSINSTALLDIR}/MSBuild") +endif() +add_custom_target(winui3_sample_app ALL + COMMAND dotnet publish "${WINUI3_SAMPLE_PROJECT}" + -c Release -p:Platform=x64 -r win-x64 --self-contained true + -o "${WINUI3_SAMPLE_OUTPUT_DIR}" + ${WINUI3_SAMPLE_MSBUILD_ARGS} + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_SOURCE_DIR}/tests/apps/WinUI3Sample/obj/x64/Release/net8.0-windows10.0.19041.0/win-x64/App.xbf" + "${WINUI3_SAMPLE_OUTPUT_DIR}/App.xbf" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_SOURCE_DIR}/tests/apps/WinUI3Sample/obj/x64/Release/net8.0-windows10.0.19041.0/win-x64/MainWindow.xbf" + "${WINUI3_SAMPLE_OUTPUT_DIR}/MainWindow.xbf" + BYPRODUCTS "${WINUI3_SAMPLE_OUTPUT_DIR}/WinUI3Sample.exe" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Publishing WinUI3 sample app" +) +file(TO_NATIVE_PATH "${WINUI3_SAMPLE_OUTPUT_DIR}/WinUI3Sample.exe" WINUI3_SAMPLE_EXE_NATIVE) +string(REPLACE "\\" "\\\\" WINUI3_SAMPLE_EXE_ESCAPED "${WINUI3_SAMPLE_EXE_NATIVE}") + # Integration tests — require a running Notepad instance add_executable(lvt_integration_tests tests/integration_tests.cpp @@ -312,6 +338,7 @@ 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 WPF_SAMPLE_EXE_PATH="${WPF_SAMPLE_EXE_ESCAPED}" + WINUI3_SAMPLE_EXE_PATH="${WINUI3_SAMPLE_EXE_ESCAPED}" ) target_link_libraries(lvt_integration_tests PRIVATE GTest::gtest GTest::gtest_main @@ -319,7 +346,7 @@ target_link_libraries(lvt_integration_tests PRIVATE comctl32 ) target_link_options(lvt_integration_tests PRIVATE "/MANIFEST:NO") -add_dependencies(lvt_integration_tests wpf_sample_app) +add_dependencies(lvt_integration_tests wpf_sample_app winui3_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/WinUI3Sample/App.xaml b/tests/apps/WinUI3Sample/App.xaml new file mode 100644 index 0000000..74ab9ee --- /dev/null +++ b/tests/apps/WinUI3Sample/App.xaml @@ -0,0 +1,5 @@ + + diff --git a/tests/apps/WinUI3Sample/App.xaml.cs b/tests/apps/WinUI3Sample/App.xaml.cs new file mode 100644 index 0000000..49a4f44 --- /dev/null +++ b/tests/apps/WinUI3Sample/App.xaml.cs @@ -0,0 +1,19 @@ +using Microsoft.UI.Xaml; + +namespace WinUI3Sample; + +public partial class App : Application +{ + private Window? window; + + public App() + { + InitializeComponent(); + } + + protected override void OnLaunched(LaunchActivatedEventArgs args) + { + window = new MainWindow(); + window.Activate(); + } +} diff --git a/tests/apps/WinUI3Sample/MainWindow.xaml b/tests/apps/WinUI3Sample/MainWindow.xaml new file mode 100644 index 0000000..c38fb40 --- /dev/null +++ b/tests/apps/WinUI3Sample/MainWindow.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + +