From 0b377d2afa6deaee7a6cb399e4f16e4fffce7b2a Mon Sep 17 00:00:00 2001 From: tfarcraw <123211521@163.com> Date: Fri, 20 Nov 2026 21:37:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=AD=A5=E9=AA=A4=E9=A1=B5?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=A0=87=E7=AD=BE=E5=90=8E=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E6=98=BE=E7=A4=BA=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VVMs/RecipeEditor/RecipeEditor.axaml | 14 +++--- tests/Avalonia.Smoke/Program.cs | 45 +++++++++++++++++++ 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml index e68e3d8..0fdf8c3 100644 --- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml +++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml @@ -1,4 +1,4 @@ - + @@ -177,7 +177,7 @@ - + @@ -185,17 +185,17 @@ - + - + - + - + @@ -228,7 +228,7 @@ - + diff --git a/tests/Avalonia.Smoke/Program.cs b/tests/Avalonia.Smoke/Program.cs index 0fbc921..0840571 100644 --- a/tests/Avalonia.Smoke/Program.cs +++ b/tests/Avalonia.Smoke/Program.cs @@ -172,6 +172,8 @@ internal static class Smoke } if(Environment.GetCommandLineArgs().Contains("--recipe-close-only")) { await CheckRecipeClose(app,lifetime);_exit=0;return; } + if(Environment.GetCommandLineArgs().Contains("--step-trigger-tabs-only")) + { await CheckStepTriggerTabs();_exit=0;return; } if(Environment.GetCommandLineArgs().Contains("--runtime-settings-only")) { var model=app.Container.Resolve(); @@ -1423,6 +1425,49 @@ internal static class Smoke Check(owner.IsVisible&&buttons.Length==2,"关闭保存提示仅有保存并关闭和不保存两个按钮"); buttons.Single(b=>b.Name==buttonName).RaiseEvent(new Avalonia.Interactivity.RoutedEventArgs(Button.ClickEvent)); } + private static async Task CheckStepTriggerTabs() + { + var model=new RecipeEditorViewModel(); + model.Recipe.AddRegion("work");model.Recipe.AddRegion("finish"); + var first=model.Recipe.AddStep();first.Detection.Method="hand_in_region"; + first.Detection.Region="work";first.Detection.FromRegion="work";first.Detection.ToRegion="finish"; + first.Detection.Hand="left";first.AiImageMode="fixed_region";first.AiImageRegion="work"; + var second=model.Recipe.AddStep();second.Detection.Method="time_elapsed"; + model.Recipe.SelectedStep=first; + var editor=new RecipeEditor{DataContext=model}; + var dialog=new Window{Content=editor,Width=1040,Height=900};dialog.Show();await Task.Delay(60); + try + { + var tabs=editor.GetVisualDescendants().OfType().First(); + var picker=editor.FindControl("StepTriggerMethodPicker")!; + var selections=editor.FindControl("StepParameters")!.GetVisualDescendants() + .OfType().Select(c=>(Picker:c,Selected:c.SelectedItem)).ToArray(); + Check(selections.Length==7&&selections.All(s=>s.Selected is not null),"Step selectors initially display all configured values"); + void CheckSelection(string expected) + { + Check(picker.SelectedItem?.ToString()==expected,"Trigger selection survives tab changes: "+expected); + Check(picker.GetVisualDescendants().OfType().Any(t=>t.Text== + ConditionMethodLabels.Converter.Convert(expected,typeof(string),null,System.Globalization.CultureInfo.InvariantCulture)?.ToString()), + "Trigger label remains displayed after tab changes: "+expected); + Check(model.Recipe.SelectedStep!.Detection.Method==expected,"Tab changes preserve the stored trigger method"); + } + CheckSelection(first.Detection.Method); + for(var index=1;indexEquals(s.Picker.SelectedItem,s.Selected)),"Region, hand and image selectors retain their selections after tab changes"); + } + model.Recipe.SelectedStep=second;await Task.Delay(30);CheckSelection("time_elapsed"); + picker.SelectedItem="hand_move";await Task.Delay(30);CheckSelection("hand_move"); + tabs.SelectedIndex=1;await Task.Delay(30);tabs.SelectedIndex=0;await Task.Delay(30); + CheckSelection("hand_move"); + model.Recipe.SelectedStep=first;await Task.Delay(30);CheckSelection("hand_in_region"); + } + finally { await model.ShutdownAsync();dialog.Close(); } + } + private static async Task CheckRecipeClose(App app,IClassicDesktopStyleApplicationLifetime lifetime) { var root=Environment.GetEnvironmentVariable("SOPHELPER_WORKSPACE_ROOT")!;