-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Open suggestion list when focus, reflect text changes
- Loading branch information
1 parent
fbadc09
commit 8dc6472
Showing
2 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_AutoSuggestBox.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using static Private.Infrastructure.TestServices; | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls | ||
{ | ||
[TestClass] | ||
[RunsOnUIThread] | ||
public class Given_AutoSuggestBox | ||
{ | ||
[TestMethod] | ||
public async Task When_Text_Changed_Should_Reflect_In_DataTemplate_TextBox() | ||
{ | ||
var SUT = new AutoSuggestBox(); | ||
SUT.Text = "New text.."; | ||
WindowHelper.WindowContent = SUT; | ||
await WindowHelper.WaitForIdle(); | ||
var textBox = (TextBox)SUT.GetTemplateChild("TextBox"); | ||
textBox.Text.Should().Be("New text.."); | ||
} | ||
|
||
[TestMethod] | ||
public async Task When_Text_Changed_And_Not_Focused_Should_Not_Open_Suggestion_List() | ||
{ | ||
var SUT = new AutoSuggestBox(); | ||
SUT.ItemsSource = new List<string>() { "ab", "abc", "abcde" }; | ||
WindowHelper.WindowContent = SUT; | ||
await WindowHelper.WaitForIdle(); | ||
|
||
var textBox = (TextBox)SUT.GetTemplateChild("TextBox"); | ||
textBox.IsFocused.Should().BeFalse(); | ||
SUT.Text = "a"; | ||
SUT.IsSuggestionListOpen.Should().BeFalse(); | ||
} | ||
|
||
[TestMethod] | ||
public async Task When_Text_Changed_And_Focused_Should_Open_Suggestion_List() | ||
{ | ||
var SUT = new AutoSuggestBox(); | ||
SUT.ItemsSource = new List<string>() { "ab", "abc", "abcde" }; | ||
WindowHelper.WindowContent = SUT; | ||
await WindowHelper.WaitForIdle(); | ||
|
||
var textBox = (TextBox)SUT.GetTemplateChild("TextBox"); | ||
SUT.Focus(FocusState.Programmatic); | ||
textBox.IsFocused.Should().BeTrue(); | ||
SUT.Text = "a"; | ||
SUT.IsSuggestionListOpen.Should().BeTrue(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters