|
1 | 1 | using MaterialDesignThemes.UITests.Samples.SplitButton;
|
2 | 2 |
|
3 |
| -[assembly:GenerateHelpers(typeof(SplitButtonWithCommandBinding))] |
| 3 | +[assembly: GenerateHelpers(typeof(SplitButtonWithCommandBinding))] |
4 | 4 |
|
5 | 5 | namespace MaterialDesignThemes.UITests.WPF.SplitButtons;
|
6 | 6 |
|
@@ -152,4 +152,41 @@ public async Task SplitButton_CommandCanExecuteFalse_DisablesButton()
|
152 | 152 |
|
153 | 153 | recorder.Success();
|
154 | 154 | }
|
| 155 | + |
| 156 | + [Fact] |
| 157 | + public async Task SplitButton_ClickingPopupContent_DoesNotExecuteSplitButtonClick() |
| 158 | + { |
| 159 | + await using var recorder = new TestRecorder(App); |
| 160 | + |
| 161 | + //Arrange |
| 162 | + IVisualElement<SplitButton> splitButton = await LoadXaml<SplitButton>(""" |
| 163 | + <materialDesign:SplitButton VerticalAlignment="Bottom" |
| 164 | + Content="Split Button" |
| 165 | + Style="{StaticResource MaterialDesignRaisedLightSplitButton}"> |
| 166 | + <materialDesign:SplitButton.PopupContent> |
| 167 | + <Button x:Name="PopupContent" /> |
| 168 | + </materialDesign:SplitButton.PopupContent> |
| 169 | + </materialDesign:SplitButton> |
| 170 | + """); |
| 171 | + |
| 172 | + IVisualElement<PopupBox> popupBox = await splitButton.GetElement<PopupBox>(); |
| 173 | + IVisualElement<Button> popupContent = await splitButton.GetElement<Button>("PopupContent"); |
| 174 | + |
| 175 | + IEventRegistration splitButtonClickEvent = await splitButton.RegisterForEvent(ButtonBase.ClickEvent.Name); |
| 176 | + IEventRegistration popupContentClickEvent = await popupContent.RegisterForEvent(ButtonBase.ClickEvent.Name); |
| 177 | + |
| 178 | + //Act |
| 179 | + await popupBox.LeftClick(); |
| 180 | + //NB: give the popup some time to show |
| 181 | + await Wait.For(async () => await popupContent.GetIsVisible()); |
| 182 | + await Wait.For(async () => await popupContent.GetActualHeight() > 10); |
| 183 | + await popupContent.LeftClick(); |
| 184 | + await Task.Delay(50); |
| 185 | + |
| 186 | + // Assert |
| 187 | + Assert.Empty(await splitButtonClickEvent.GetInvocations()); |
| 188 | + Assert.Single(await popupContentClickEvent.GetInvocations()); |
| 189 | + |
| 190 | + recorder.Success(); |
| 191 | + } |
155 | 192 | }
|
0 commit comments