Files
pacs_win_uia/tests/regression/RegressionTests.csproj
zimoyin 529f7910a1 新增跨来源取值键「文本内容」,修好富文本/输入框读不到内容
问题:富文本(RichTextBox、Chromium/CEF、UWP 文本框)的 UIA Name 往往是通用标题
(实测夹具里是 "RichEdit Control"),真正的内容只在 ValuePattern/TextPattern 里;
而新增监控项时默认 ValueKey 是 Name,于是读回来的是标题而不是内容。

- ControlValueKeys 新增跨来源键「文本内容」:UIA 按 Value → Text → Name 顺序取,
  MSAA = accValue → accName,Win32 = 窗口标题;三种都取不到才报错并说明各自原因
- 新增/拾取控件时默认 ValueKey 改为「文本内容」(旧条目不受影响,仍按各自保存的键读)
- 「文本内容」加进三个来源的可选键列表,监控列表下拉里能直接选
- 夹具新增多行富文本 FixtureRichText(内容只在 Value/Text 里)
- 回归新增 ValueKeyTests(键表、Name 兜底、默认键),共 27/27 通过

实测(跨进程,目标为独立进程里的夹具窗口):
- 文本框 文本内容="可编辑文本";富文本 文本内容="富文本第一行\r富文本第二行\r";
  按钮(无 Value/Text 模式)自动退回 Name="测试按钮"
- 拾取点在两个控件上都精确命中 Edit / Document,且能在窗口树里找到同一节点
- 无界面读取端到端:2 条配置(//Document[...]、//Edit[...] + 文本内容)全部命中并取到值
2026-10-13 16:22:03 +08:00

54 lines
2.8 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!--
回归测试工程(net48 控制台程序,AssemblyName = RegressionTests)。
引用主项目 pacs_win_uia 与几个受测的 WinForms/服务类型,在纯内存快照或本进程
自建控件上跑断言;不调用 UIA 读自身控件树(会崩溃),真实 UIA 场景见 tests/uia-fixture。
运行:用隔离的 OutputPath 构建后再直接跑 exe,避免锁定 src 正在使用的 bin\Debug:
dotnet msbuild tests\regression\RegressionTests.csproj -t:Build -p:Configuration=Debug
-p:OutputPath=<隔离目录>\ -v:minimal
<隔离目录>\RegressionTests.exe (退出码 0 全通过 / 1 有失败)
-->
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{734FCA9D-3071-48D1-91DF-C2A07B329512}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>PacsWinUia.RegressionTests</RootNamespace>
<AssemblyName>RegressionTests</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>false</Prefer32Bit>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml" />
</ItemGroup>
<!-- 引用主项目:测试直接调用其 ControlPath / ControlLocatorService / Store / FloatingBarManager 等类型。 -->
<ItemGroup>
<ProjectReference Include="..\..\src\pacs_win_uia\pacs_win_uia.csproj">
<Project>{C74B0B3A-0FB4-47CB-9AE8-DC7E0D993202}</Project>
<Name>pacs_win_uia</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="PathTests.cs" />
<Compile Include="PersistenceTests.cs" />
<Compile Include="TreeRefreshTests.cs" />
<Compile Include="FloatingConditionsTests.cs" />
<Compile Include="SettingsComboBoxTests.cs" />
<Compile Include="WindowVisibilityTests.cs" />
<Compile Include="ValueKeyTests.cs" />
<!-- 把主项目的 ControlTreeReconciler 以链接方式编译进测试程序集(部分内部成员需要同程序集可见)。 -->
<Compile Include="..\..\src\pacs_win_uia\UI\ControlTreeReconciler.cs"><Link>ControlTreeReconciler.cs</Link></Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>