Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2a90e3c
Implement the AutoSuggestion in TextBox by using TextFieldAssist.Auto…
AbderrahmaneAhmam May 20, 2023
b3e1d3f
Fixing the code warnings about the null values
AbderrahmaneAhmam May 21, 2023
1e7552d
Fix warnings in the FieldsViewModel 0 Warning(s)
AbderrahmaneAhmam May 21, 2023
0f1bb1c
Add underscore prefix to the private properties
AbderrahmaneAhmam May 22, 2023
6d41235
Reset changes of the AutoSuggestion in the TextFieldAssist
AbderrahmaneAhmam May 27, 2023
d509195
creation of control AutoSuggestBox Based on TextBox with custom Templ…
AbderrahmaneAhmam Jun 19, 2023
dbaa4e3
Fix Warnings
AbderrahmaneAhmam Jun 19, 2023
e0d3ed0
Rebase build fixing
Keboo Aug 10, 2023
7d85d89
Adding some TODOs, starting on the UI tests
Keboo Aug 10, 2023
03ec8e4
Merge branch 'MaterialDesignInXAML:master' into feature/AutoSuggestion
AbderrahmaneAhmam Aug 12, 2023
aa7b202
Merge branch 'master' of https://github.com/AbderrahmaneAhmam/Materia…
AbderrahmaneAhmam Aug 12, 2023
0fdfbd7
Merge branch 'feature/AutoSuggestion' of https://github.com/Abderrahm…
AbderrahmaneAhmam Aug 12, 2023
829e298
Remove AutoSuggestBox from properties
AbderrahmaneAhmam Aug 12, 2023
e6b148a
Implement the tests:
AbderrahmaneAhmam Aug 12, 2023
26f2c22
WIP showing sample test for ICollectionView
Keboo Aug 13, 2023
9946cab
Merge branch 'MaterialDesignInXAML:master' into feature/AutoSuggestion
AbderrahmaneAhmam Aug 14, 2023
408708b
Merge branch 'MaterialDesignInXAML:master' into feature/AutoSuggestion
AbderrahmaneAhmam Aug 17, 2023
8d8889e
Use ICollectionView for keyboard navigation and ensure completion of …
AbderrahmaneAhmam Sep 3, 2023
d47c665
rename key
AbderrahmaneAhmam Sep 3, 2023
e1f4419
Merge branch 'MaterialDesignInXAML:master' into feature/AutoSuggestion
AbderrahmaneAhmam Sep 3, 2023
596f708
Merge branch 'master' of https://github.com/AbderrahmaneAhmam/Materia…
AbderrahmaneAhmam Sep 3, 2023
82bee7a
Merge branch 'feature/AutoSuggestion' of https://github.com/Abderrahm…
AbderrahmaneAhmam Sep 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement the tests:
- Validates these elements are found
- Validate other items are hidden
- Validate that the current text is the same as the selected item
  • Loading branch information
AbderrahmaneAhmam committed Aug 12, 2023
commit e6b148a36b61b56cbe44de530d6f7c7deb0c6e0d
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
d:DesignHeight="450" d:DesignWidth="800">
<!-- TODO SELECTED ITEM -->
<materialDesign:AutoSuggestBox
materialDesign:HintAssist.HelperText="Select your color"
materialDesign:HintAssist.HelperText="Name"
materialDesign:TextFieldAssist.HasClearButton="True"
Text="{Binding AutoSuggestText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Suggestions="{Binding Suggestions}"
ValueMember="Name"
DisplayMember="Name">
</materialDesign:AutoSuggestBox>
</UserControl>
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using MaterialDesignThemes.UITests.Samples.AutoSuggestTextBoxes;
using System.Collections.ObjectModel;
using System.Windows.Controls;
using MaterialDesignThemes.UITests.Samples.AutoSuggestTextBoxes;
using XamlTest;
using static System.Net.Mime.MediaTypeNames;

namespace MaterialDesignThemes.UITests.WPF.AutoSuggestBoxes;

Expand All @@ -22,18 +26,64 @@ public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggesti
await suggestBox.MoveKeyboardFocus();
await suggestBox.SendInput(new KeyboardInput("B"));


//Assert
Assert.True(await suggestBox.GetIsPopupOpen());
Assert.True(await suggestBox.GetIsSuggestionOpen());
Assert.True(await popup.GetIsOpen());

//Validates these elements are found
_ = suggestionListBox.GetElement(ElementQuery.PropertyExpression<TextBlock>(x => x.Text, "Bananas"));
_ = suggestionListBox.GetElement(ElementQuery.PropertyExpression<TextBlock>(x => x.Text, "Beans"));
await AssertExists(suggestionListBox, "Bananas");
await AssertExists(suggestionListBox, "Beans");

//Validate other items are hidden
await AssertExists(suggestionListBox, "Apples", false);
await AssertExists(suggestionListBox, "Mtn Dew", false);
await AssertExists(suggestionListBox, "Orange", false);

recorder.Success();
}

[Fact]
public async Task CanChoiseItem_FromTheSuggestions_AssertTheTextUpdated()
{
await using var recorder = new TestRecorder(App);

//Arrange
IVisualElement<AutoSuggestBox> suggestBox = (await LoadUserControl<AutoSuggestTextBoxWithTemplate>()).As<AutoSuggestBox>();
IVisualElement<Popup> popup = await suggestBox.GetElement<Popup>();
IVisualElement<ListBox> suggestionListBox = await popup.GetElement<ListBox>();

//Act
await suggestBox.MoveKeyboardFocus();
await suggestBox.SendInput(new KeyboardInput("B"));

//TODO: Validate other items are hidden
//Assert
Assert.True(await suggestBox.GetIsSuggestionOpen());
Assert.True(await popup.GetIsOpen());

//Choise Item from the list
var bananas = await suggestionListBox.GetElement<ListBoxItem>("/ListBoxItem[0]");
await Task.Delay(100);
await bananas.LeftClick();
var suggestBoxText = await suggestBox.GetText();
//Validate that the current text is the same as the selected item
Assert.Equal("Bananas", suggestBoxText);

recorder.Success();
}

//TODO: Test case with ICollectionSource

private async Task AssertExists(IVisualElement<ListBox> suggestionListBox, string text, bool existsOrNotCheck = true)
{
try
{
_ = await suggestionListBox.GetElement(ElementQuery.PropertyExpression<TextBlock>(x => x.Text, text));
Assert.True(existsOrNotCheck);
}
catch (Exception)
{
Assert.True(!existsOrNotCheck);
}
}
}
2 changes: 0 additions & 2 deletions MaterialDesignThemes.Wpf/AutoSuggestBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public class AutoSuggestBox : TextBox

#region Dependency Properties

//TODO: Remove "AutoSuggestBox" prefix from all properties

public IEnumerable Suggestions
{
get => (IEnumerable)GetValue(SuggestionsProperty);
Expand Down