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")!;